By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,652 Members | 1,337 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,652 IT Pros & Developers. It's quick & easy.

Disable ListItem in Drop Down List

P: n/a
I am trying to disable a list item in a drop down list.

The list looks something like

"Item 1

Other items that may interest you

Item 2
Item 3"

So items with an index of 1, 2 and 3 should not be selectable as I do not
want them to fire the onselectedindexchange.

I know that there is an enabled property but that this does not apply to
dropdownlists.

Does anyone know of another way I can disable these items?

Thanks for your help.
Aug 28 '07 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Just remove the unwanted items from the list, then users can't select them.

"KerryC" <Ke****@discussions.microsoft.comwrote in message
news:3A**********************************@microsof t.com...
>I am trying to disable a list item in a drop down list.

The list looks something like

"Item 1

Other items that may interest you

Item 2
Item 3"

So items with an index of 1, 2 and 3 should not be selectable as I do not
want them to fire the onselectedindexchange.

I know that there is an enabled property but that this does not apply to
dropdownlists.

Does anyone know of another way I can disable these items?

Thanks for your help.

Aug 28 '07 #2

P: n/a
Obviously that would be nice but I need to keep them in there!

"schneider" wrote:
Just remove the unwanted items from the list, then users can't select them.

"KerryC" <Ke****@discussions.microsoft.comwrote in message
news:3A**********************************@microsof t.com...
I am trying to disable a list item in a drop down list.

The list looks something like

"Item 1

Other items that may interest you

Item 2
Item 3"

So items with an index of 1, 2 and 3 should not be selectable as I do not
want them to fire the onselectedindexchange.

I know that there is an enabled property but that this does not apply to
dropdownlists.

Does anyone know of another way I can disable these items?

Thanks for your help.


Aug 28 '07 #3

P: n/a
I'm not aware of any way to do this in the way that you want. The only way
I can think of to do something like this is to handle it manually.

For instance if you don't want to allow "Item 2" to be selected, you could
use something like:
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged

If ComboBox1.SelectedItem.ToString() = "Item 2" Then
ComboBox1.SelectedIndex += 1

End Sub

Of course, this has a couple of problems such as incrementing past the last
item, etc. What you would have to do is keep track of the current value of
ComboBox - then depending on whether you allow the change, update the
manually tracked value and allow the change or manually set the combo box
back to the value stored previously.

HTH (as hokey as it is)
Aug 28 '07 #4

P: n/a
Possible use the Validation events, Causes Validation property?
"Matt F" <mf****************@nospam.nospamwrote in message
news:eh**************@TK2MSFTNGP02.phx.gbl...
I'm not aware of any way to do this in the way that you want. The only
way I can think of to do something like this is to handle it manually.

For instance if you don't want to allow "Item 2" to be selected, you could
use something like:
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged

If ComboBox1.SelectedItem.ToString() = "Item 2" Then
ComboBox1.SelectedIndex += 1

End Sub

Of course, this has a couple of problems such as incrementing past the
last item, etc. What you would have to do is keep track of the current
value of ComboBox - then depending on whether you allow the change, update
the manually tracked value and allow the change or manually set the combo
box back to the value stored previously.

HTH (as hokey as it is)


Aug 28 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.