I'm assuming I'm missing something here, but I seem to be having a
problem in the selectedindexchanged routine when using different
comboboxes. I have two comboboxes and when I change the value in one,
I want the other one to be set to blank. I tried setting the text
property to "" but that does nothing, so then I tried setting the
selectedindex to -1 and that works, but the combobox that I'm actually
changing never gets changed it stays blank too, but the second time I
change the value in the combobox, it actually changes...what's going
on here, am I doing something in the wrong order?

CODE:
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
ComboBox1.SelectedIndexChanged
ComboBox2.SelectedIndex = -1
End Sub

Private Sub ComboBox2_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
ComboBox2.SelectedIndexChanged
ComboBox1.SelectedIndex = -1
End Sub

RE: Simple ComboBox Question by Nicky

Nicky
Tue Aug 23 13:25:27 CDT 2005

I think when you selected the first one, the code will change the second one
to blank, as you expected. But when ComBox2.SelectedIndex got set, it will
fire ComBox2_SelectedIndexChanged event too, which will cause the first one
goes back to -1.

"Beebs" wrote:

> I'm assuming I'm missing something here, but I seem to be having a
> problem in the selectedindexchanged routine when using different
> comboboxes. I have two comboboxes and when I change the value in one,
> I want the other one to be set to blank. I tried setting the text
> property to "" but that does nothing, so then I tried setting the
> selectedindex to -1 and that works, but the combobox that I'm actually
> changing never gets changed it stays blank too, but the second time I
> change the value in the combobox, it actually changes...what's going
> on here, am I doing something in the wrong order?
>
> CODE:
> Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As
> System.Object, ByVal e As System.EventArgs) Handles
> ComboBox1.SelectedIndexChanged
> ComboBox2.SelectedIndex = -1
> End Sub
>
> Private Sub ComboBox2_SelectedIndexChanged(ByVal sender As
> System.Object, ByVal e As System.EventArgs) Handles
> ComboBox2.SelectedIndexChanged
> ComboBox1.SelectedIndex = -1
> End Sub
>

Re: Simple ComboBox Question by Beebs

Beebs
Tue Aug 23 14:19:47 CDT 2005

That makes sense to me, but how can I set the text then in the other
combobox to an empty string, or make it so no value appears when the
other combobox has their value change?

On Tue, 23 Aug 2005 11:25:27 -0700, "Nicky"
<Nicky@discussions.microsoft.com> wrote:

>I think when you selected the first one, the code will change the second one
>to blank, as you expected. But when ComBox2.SelectedIndex got set, it will
>fire ComBox2_SelectedIndexChanged event too, which will cause the first one
>goes back to -1.