Board index » Visual Studio » how to make one by one combo Box working?

how to make one by one combo Box working?

Visual Studio207
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


-
 

Re:how to make one by one combo Box working?

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



"Tony Dong" <itdong@hotmail.com>wrote in message

Quote
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











-

Re:how to make one by one combo Box working?

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



"solex" <solex@nowhere.com>wrote in message

Quote
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



"Tony Dong" <itdong@hotmail.com>wrote in message

news:uogR3czkDHA.2528@TK2MSFTNGP10.phx.gbl...

>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

>

>

>









-

Re:how to make one by one combo Box working?

Tony,



you might want to check this article:

www.bobpowell.net/ComboBinding.htm">www.bobpowell.net/ComboBinding.htm



Dan



"Tony Dong" <itdong@hotmail.com>wrote in message

Quote
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



"solex" <solex@nowhere.com>wrote in message

news:e56jkizkDHA.392@TK2MSFTNGP11.phx.gbl...

>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

>

>"Tony Dong" <itdong@hotmail.com>wrote in message

>news:uogR3czkDHA.2528@TK2MSFTNGP10.phx.gbl...

>>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

>>

>>

>>

>

>









-