Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I make a combobox stay open after an item has been selected?

How do I make a combobox stay open after an item is selected in C#?

I want to do this because it is actually a comboBox with a checklist so I can select several items.

like image 958
aharon Avatar asked Feb 13 '11 08:02

aharon


People also ask

How do you readonly ComboBox?

Just change the DropDownStyle to DropDownList . Or if you want it completely read only you can set Enabled = false , or if you don't like the look of that I sometimes have two controls, one readonly textbox and one combobox and then hide the combo and show the textbox if it should be completely readonly and vice versa.

What events would a ComboBox fire upon selecting a new item?

It records the currently selected item when the dropdown is opened, and then fires SelectionChanged event if the same index is still selected when the dropdown is closed. It may need to be modified for it to work with Keyboard selection.

Which method is used to get the selected item in ComboBox control?

The ComboBox class searches for the specified object by using the IndexOf method.

How do I stop a ComboBox from editing?

We can disable the combobox by passing the state as “readonly”.


2 Answers

Use ListBox instead, since ComboBox does that behavior by its core design.

ListBox gives a similar effect (hence it is still open) and enabling for multi-selection.

like image 178
Ken D Avatar answered Sep 28 '22 15:09

Ken D


If you still want to allow the user to write an option of his own you can still use a DropBox, just set the DropDownStyle property to simple. You'll get something similar with a ListBox but with an TextBox on the top where the user can write somwthing.

like image 24
Adrian Fâciu Avatar answered Sep 28 '22 16:09

Adrian Fâciu