I have been looking over some old vb 6 code and I noticed that there was a way to set the index of a listbox to a new value. For instance, if you wanted to populate a listbox with items from a database you could assign an id value from the table as the index value so that it is easier to relate back to the database. Does anyone know if and how to do this in vb.net?

When you bind data to a listbox, most of the time the indexs are the same order as the data records in your table so it might not be a good idea to change item indexs directly.

You can use the valuemember property of an item to hold an invisible value that can equate to your table index.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.