Click here to Skip to main content
15,867,453 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
Hello Guys, i want to know
C#
how to disable dropdown of combo box  without disable combobox in c#


What I have tried:

C#
Hello Guys, i want to know <pre lang="C#">how to disable dropdown of combo box  without disable combobox</pre>
Posted
Updated 15-Dec-16 4:02am
Comments
Dave Kreskowiak 14-Dec-16 19:57pm    
Ummm ... why? Disabling that would make it a TextBox.
Philippe Mori 15-Dec-16 10:04am    
WinForms or WPF. I have assumed WinForms in my answer as you could do almost anything you want in WPF and it would not make much sense to ask a WPF question without specifying it.

1 solution

You should essentially never do something that make a standard control behave in an unexpected way.

If you don't want to show the list, then why are you using a combo box to start with?

The simple approach is to leave the list empty. It is not the best UI both in many cases one might might prefer no to bother with the exceptional case that the combo is empty.

Well, when the combo is a read-only list (not editable), I would usually disable the combo if there are 0 or 1 item in its list.

Having said that, the other alternative would be to use either a TextBox or a ComboBox depending on the case. You would then only show the appropriate control. The advantage of that solution is that you won't display a combo when you want text box behavior.

It might also be possible to hack the combo box but this is probably undocumented anyway... so it is a bit riskier.
 
Share this answer
 

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