Greetings,
I need to access a certain item in a listbox and then save it to a textbox. For example, I have a listbox with 5 items and 5 textboxes, and I need one item per textbox. What is the code necessary to access individual items in a textbox?
![]() |
Greetings,
I need to access a certain item in a listbox and then save it to a textbox. For example, I have a listbox with 5 items and 5 textboxes, and I need one item per textbox. What is the code necessary to access individual items in a textbox?
I don't know if you have an answer yet or not, but it all depends on how the data is bound to the ListBox.
You can access a specific item in a ListBox using the Items() collection:
ListBox.Items(0) for the first item in the list.
If the data is an array of String:
TextBox1.Text = ListBox.Items(0)
If the data is a DataTable:
TextBox1.Text = DirectCast(ListBox1.Items(0), DataRowView).Item(<column name or number>)
If the data is a custom object:
TextBox1.Text = DirectCast(ListBox1.Items(0), CustomObject).PropertyName
All times are GMT -7. The time now is 10:31 PM. |