how to make one by one combo Box working?

  • Thread starter Thread starter Tony Dong
  • Start date Start date
T

Tony Dong

Hi there

I have three comboBoxs
I need the first comboBox selected and fill the second comboBox, after
second comboBox selected, it will fill the last comboBox, When I use
selectedIndex change event, it happens before I select second comboBox,
because when I selected first one, it auto fill the second one and make the
selectedindexchanged event happen, how can I disable it untial I select
second comboBox?
how can I do to make this one working?


the code as follow

Thanks

Tony


Private Sub cmbLastName_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
cmbLastName.SelectedIndexChanged
Dim bl As New BusinessLogic
cmbFirstName.DataSource =
bl.FillClientsFirstNameInfo(cmbLastName.Text).Tables(0).DefaultView
cmbFirstName.DisplayMember = "ClientsFirstName"
cmbFirstName.ValueMember = "CustomerID"
End Sub

Private Sub cmbFirstName_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
cmbFirstName.SelectedIndexChanged
MessageBox.Show(cmbFirstName.SelectedValue.ToString)
End Sub
 
Tony,

I had a tough time reading your description, in any event you might want to
consider using a flag, a private boolean variable in the form (i.e.
InProcess)

Set the value to TRUE in the active combo boxes SelectedIndex event then
call the procedure to fill the second or third combo boxes then set the
value back to False. In the SelectedIndex Change event you should always
check to see if InProcess is True if so then exit the event.

Dan
 
Hi Solex

Thanks for you to reply so quickly, I don't know why when I use databinding
function, this event happen everything and cause the problems, but when I
use comboBox.items.add, it was working fine. I will change the databind to
items.add function, may it will be easy.

anyway, thanks for your help


Tony
 
Back
Top