ComboBox question

  • Thread starter Thread starter Dino Buljubasic
  • Start date Start date
D

Dino Buljubasic

I have a combo box with items as:

1 - can be selected
2 - currently selected
3 - can NOT be selected
4 - can NOT be selected
5 - can NOT be selected

my currently selected item is 2. I want to allow user to select any
item thant is <= current item (1, or 2), but not any of items > 2
(3, 4, 5).

If user select any of items 3, 4, or 5, he should be notified that
that is invalid selecting and combo box should reset itself to the
current item (item 2)

How can I do that?

Thanks
Dino
 
Hi,

I do not know of any way to disable an item in a combobox. You
would have to filter the items in the combobox so only the valid items are
available to select.

Ken
---------------
I have a combo box with items as:

1 - can be selected
2 - currently selected
3 - can NOT be selected
4 - can NOT be selected
5 - can NOT be selected

my currently selected item is 2. I want to allow user to select any
item thant is <= current item (1, or 2), but not any of items > 2
(3, 4, 5).

If user select any of items 3, 4, or 5, he should be notified that
that is invalid selecting and combo box should reset itself to the
current item (item 2)

How can I do that?

Thanks
Dino
 
This should do it:

Code:
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged

If ComboBox1.SelectedIndex > 1 Then

MessageBox.Show("Unauthorised selection")

ComboBox1.SelectedIndex = 1

End If

End Sub





HTH

Ged
 
Back
Top