Selecting Listbox Item Based On Textbox.Text Value - MORE INFO
Anybody have any idea how to select a listbox item to equal the text value in a textbox? My aim is to already have the Customer selected in the ListBox when they go to the next tab. I'm thinking maybe this needs to be done in a TabIndexChanged event or something.
I've tried :
VB Code:
lbxRecCust.SelectedItem.Item(0)=txtCustomerName.Text
lbxRecCust.SelectedValue = txtCustomerName.Text
lbxRecCust.SelectedIndex=txtCustomerName.Text
And a couple of others...not sure how to handle this here.
MORE INFO - When I used the first option, it does not select the item, and when I manually select an item, I get an error that highlights my sql statement that fills in the partnumber listbox (from yesterday's discussion), and gives me a System.NullReferenceException (object reference not set...)
Re: Selecting Listbox Item Based On Textbox.Text Value - MORE INFO
It seems like your second option should work. If you are using a dataset, do you have the ValueMember property of the listbox set?
Re: Selecting Listbox Item Based On Textbox.Text Value - MORE INFO
I am not using a ValueMember property. There are none available. I'm doing all the db stuff manually.