Questions tagged [combobox]

Combobox allows to select one option out of several (similar to a dropdownlist), or to type a custom option.

allows to select one option out of several (similar to a ), or to type a custom option. The main difference with the is thus that it's editable.

Although comboboxes are primarily meant for single selection they may be customized to support multiple selections.

, and are quite similar. However, is a read-only dropdown list of options and is a read-only list of options. Whereas in case of , the user can either select from the dropdownlist or type a value directly into the input field.

Drop-down list is sometimes also refered to as non-editable version of combobox.

See Wikipedia entry for Combobox.

18062 questions
237
votes
21 answers

ComboBox: Adding Text and Value to an Item (no Binding Source)

In C# WinApp, how can I add both Text and Value to the items of my ComboBox? I did a search and usually the answers are using "Binding to a source".. but in my case I do not have a binding source ready in my program... How can I do something like…
Bohn
  • 26,091
  • 61
  • 167
  • 254
236
votes
27 answers

How do I set the selected item in a comboBox to match my string using C#?

I have a string "test1" and my comboBox contains test1, test2, and test3. How do I set the selected item to "test1"? That is, how do I match my string to one of the comboBox items? I was thinking of the line below, but this doesn't…
May D
228
votes
7 answers

How can I make a ComboBox non-editable in .NET?

I want to have a "select-only" ComboBox that provides a list of items for the user to select from. Typing should be disabled in the text portion of the ComboBox control. My initial googling of this turned up an overly complex, misguided suggestion…
Cory Engebretson
  • 7,653
  • 4
  • 22
  • 17
207
votes
4 answers

Binding a WPF ComboBox to a custom list

I have a ComboBox that doesn't seem to update the SelectedItem/SelectedValue. The ComboBox ItemsSource is bound to a property on a ViewModel class that lists a bunch of RAS phonebook entries as a CollectionView. Then I've bound (at separate times)…
Geoff Bennett
  • 2,513
  • 2
  • 16
  • 13
177
votes
4 answers

How to disable editing of elements in combobox for c#?

I have some elements in a ComboBox (WinForms with C#). I want their content to be static so that a user cannot change the values inside when the application is ran. I also do not want the user adding new values to the ComboBox
Mobin
  • 4,870
  • 15
  • 45
  • 51
140
votes
21 answers

How do I have an enum bound combobox with custom string formatting for enum values?

In the post Enum ToString, a method is described to use the custom attribute DescriptionAttribute like this: Enum HowNice { [Description("Really Nice")] ReallyNice, [Description("Kinda Nice")] SortOfNice, [Description("Not Nice At All")] …
Shalom Craimer
  • 20,659
  • 8
  • 70
  • 106
139
votes
28 answers

Binding an enum to a WinForms combo box, and then setting it

a lot of people have answered the question of how to bind an enum to a combo box in WinForms. Its like this: comboBox1.DataSource = Enum.GetValues(typeof(MyEnum)); But that is pretty useless without being able to set the actual value to display. I…
Tony Miletto
127
votes
24 answers

How to display default text "--Select Team --" in combo box on pageload in WPF?

In a WPF app, in MVP app, I have a combo box,for which I display the data fetched from Database. Before the items added to the Combo box, I want to display the default text such as " -- Select Team --" so that on pageload it displays and on…
user301016
  • 2,207
  • 7
  • 36
  • 50
119
votes
7 answers

How to bind a List to a ComboBox?

I want to connect a BindingSource to a list of class objects and then objects value to a ComboBox. Can anyone suggest how to do it? public class Country { public string Name { get; set; } public IList Cities { get; set; } public…
Mobin
  • 4,870
  • 15
  • 45
  • 51
115
votes
6 answers

twitter bootstrap autocomplete dropdown / combobox with Knockoutjs

I have a requirement where I HAVE TO use bootstrap autocomplete dropdown, BUT user can have free form text in that dropdown if they wish. Before you think about TypeAhead, I could use Bootstrap TypeAhead textbox, but I need to have the dropdown…
108
votes
19 answers

ComboBox- SelectionChanged event has old value, not new value

C#, .NET 4.0, VS2010. New to WPF. I have a ComboBox on my MainWindow. I hooked the SelectionChanged event of said combo box. However, if I examine the value of the combo box in the event handler, it has the old value. This sounds more like a…
Matt
  • 41,216
  • 30
  • 109
  • 147
106
votes
13 answers

How can I make a WPF combo box have the width of its widest element in XAML?

I know how to do it in code, but can this be done in XAML ? Window1.xaml:
Jeno Csupor
  • 2,869
  • 6
  • 30
  • 35
1
2 3
99 100