Click here to Skip to main content
15,918,485 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am working with two comboboxes.

When I select combobox1 all the files from the directory are listed in the comboBox2.

I want to lock the item selected by user in combobox1 so no other user can select the same item. I have corresponding database where status flag will be saved.

Any help or suggestions appreciated.

Thanks.
Posted
Updated 9-Nov-15 12:25pm
v2
Comments
Sergey Alexandrovich Kryukov 9-Nov-15 18:14pm    
It depends on the UI framework/library you are using. Normal combo box does not have items which could be disabled. What is that supposed to mean? You can disable some input control, not list element. If you have a clear idea what you want to achieve, I'll probably advise.
—SA
Member 12076824 9-Nov-15 18:26pm    
I am trying to lock selected item when user1 selects the item, so that user2 cannot select the same item that's being worked on.

Thanks.
BillWoodruff 9-Nov-15 20:39pm    
Why not set the 'Enabled property of ComboBox1 to 'false when there's an active user ?
Member 12076824 10-Nov-15 11:29am    
Thanks for response. That would be good option, but in my case multiple user should be able to work at the same time. So If user 1 starts working on batch1 that will be locked and other user will not be able to select same batch.

1 solution

If your goal is to disable certain items in a ComboBox it can be done by using the DrawItem and SelectedIndexChanged event.
You also need to determine the logic for which item index(es) that should be grayed out.

Here is an example from StackOverflow Disabling particular Items in a Combobox[^] that you can use as a starting point.

I would not recommend to use hard coded indexes like in that example, though.

And if this is the right controls to use in order to implement your solution is a different story.
 
Share this answer
 
v2
Comments
Member 12076824 10-Nov-15 11:44am    
Thanks for the response, I will try this.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900