473,703 Members | 3,336 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Disable ListItem in Drop Down List

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 onselectedindex change.

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
4 2613
Just remove the unwanted items from the list, then users can't select them.

"KerryC" <Ke****@discuss ions.microsoft. comwrote in message
news:3A******** *************** ***********@mic rosoft.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 onselectedindex change.

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
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****@discuss ions.microsoft. comwrote in message
news:3A******** *************** ***********@mic rosoft.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 onselectedindex change.

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
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_Selec tedIndexChanged (ByVal sender As System.Object,
ByVal e As System.EventArg s) Handles ComboBox1.Selec tedIndexChanged

If ComboBox1.Selec tedItem.ToStrin g() = "Item 2" Then
ComboBox1.Selec tedIndex += 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
Possible use the Validation events, Causes Validation property?
"Matt F" <mf************ ****@nospam.nos pamwrote in message
news:eh******** ******@TK2MSFTN GP02.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_Selec tedIndexChanged (ByVal sender As System.Object,
ByVal e As System.EventArg s) Handles ComboBox1.Selec tedIndexChanged

If ComboBox1.Selec tedItem.ToStrin g() = "Item 2" Then
ComboBox1.Selec tedIndex += 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
17075
by: MEM | last post by:
hello, I'd like to 'disable' an image link based on a value selected in a drop down. I currently have an image link that has the onclick event set to execute a function. For example:
2
12620
by: Yoshitha | last post by:
hi I have 2 drop down lists in my application.1st list ontains itmes like java,jsp,swings,vb.net etc.2nd list contains percentage i.e it conatains the items like 50,60,70,80,90,100. i will select any skill in 1st drop down list then i'll select % of this skill in the 2nd list box , based on the percentage i've selected in the 2nd list box it has to display 2 sets of drop down list boxes at run time one for selecting skill and
1
3200
by: Dante | last post by:
When your selected on a combo box, and hit F4, it shows the drop down list. So how do i stop the F4 key from bringing up the drop down list on a combo box?
1
1487
by: Ami Schreiber | last post by:
I want to insert a default null ListItem with the text "choose an item ..." in my DropDownList control. I have seen similar postings here regarding this issue but all of them seem to focus around having to populate datasources, datatables etc. and then bind the DropDownList in the codebehind of the .aspx page. I am using Visual Studio 2005 and the .NET Framework 2.0. I thought that with all these new improvements we could avoid all of the...
5
1849
by: Mark Rae | last post by:
Hi, Has the <asp:DropDownList> - <asp:ListItem> functionality changed in v2? In v1.1, the following works as expected: <asp:DropDownList ID="cmbStatus" Runat=server EnableViewState=False> <asp:ListItem Value=0>&nbsp;</asp:ListItem> <asp:ListItem Value=1>Awaiting</asp:ListItem> <asp:ListItem Value=2>Current</asp:ListItem> <asp:ListItem Value=3>Terminated</asp:ListItem>
0
3717
kestrel
by: kestrel | last post by:
im making a drop down list, and i want to disable only certain options how can i do this?
4
9292
by: TycoonUK | last post by:
Hi, As I do not have IE7 on my computer, I was wondering if there is a fault in my CSS Menu when using IE7. Please can someone look at my site - http://www.worldofmonopoly.co.uk and tell me if it works, and if it does not, tell me why it does not work. Thanks.
3
7358
by: penny111 | last post by:
Hi there, For my application, i need to have 3 drop down lists 1. drop down list of folder names 2. drop down list of documents in the folder selected 3. drop down list of instances of the document selected (my application uses the BusinessObjects Java Web Services SDK) The 2nd list is dependent on the 1st, while the 3rd list is dependent on the 2nd. In other words, this is what i want my application to do -select a folder from the...
1
1837
by: bhavanirayala | last post by:
Hi, I want to disable drop down list according to the selection on radio buttons. my code <td > SEARCH </td> <td><input type="radio" name="letterOption" ></td> <td> <select name="letter"/> </td> <td><input type="radio" name="fileOption" ></td> <td> <select name="fileName"/> </td>
0
9109
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9002
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8956
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6585
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5922
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4420
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4677
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2057
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.