Get Selected Value of a ComboBox in C#
In this tutorial, you will learn the different methods to get the selected text and values of a ComboBox in C#. The most common method of getting a ComboBox control’s selected value is fetching it in a button click event using C#.
A ComboBox control in C# provides a combined functionality of a text box and a list box in a single control. The two primary methods to display and get the selected value of a ComboBox are using Combobox.SelectedItem and ComboBox.GetItemText properties in C#.
A selected item’s value can be retrieved using the SelectedValue property. You can create a ComboBox control using a Forms designer at design-time or using the ComboBox class in C# code at run-time.
Use the ComboBox.SelectedItem Property to Get the Selected Value of a ComboBox in C#
In .NET’s ComboBox control, the .SelectedItem property displays a string representation of the selected value. The ComboBox.SelectedItem property of a ComboBox in C# can get or set the currently selected item in a ComboBox.
The selected value of a ComboBox is null initially and only be assigned after the user sets the SelectedItem property to an object. When a user clicks on a value of a ComboBox, the value becomes the currently selected object/value in the list.
Use ComboBox.GetItemText to Get Selected Value of a Combobox in C#
The this.comboBox1.GetItemText(value) property of a ComboBox helps retrieve the displayed or selected value to a string variable. It’s extremely crucial for the selected item; however, there are times when it’s useful for the other values of a ComboBox.
The GetItemText method of getting the selected value of a combo box is consistent with the definition of the existing SelectedValue property and its implementation. It’ll return null when the provided object doesn’t belong in the control’s list, and it’ll return the value itself if it’s valid and the ValueMember is not set.
If you are unfamiliar, you can add a new class to your WinForms project, add the following code, and then build your project to have a new control ready to be dragged onto a form.
Create an instance of the ComboBox’s class, set its properties, and add a ComboBox instance to the Form controls to create a ComboBox control at run-time. Either you can set control properties of a ComboBox at design time or from the Properties Window of the Visual Studio IDE.
The value of ComboBox.SelectedText is empty at the start because the SelectedText property gets and sets the selected text in a ComboBox only when it has focused on it. If the focus moves away, its value will be an empty string.
In this article, you have learned to get the selected value of a ComboBox in C# at design-time and run-time. After that, you have discovered various properties and methods of ComboBox control in Windows Forms to get selected values.
Hassan is a Software Engineer with a well-developed set of programming skills. He uses his knowledge and writing capabilities to produce interesting-to-read technical articles.
C# ComboBox Control
C# controls are located in the Toolbox of the development environment, and you use them to create objects on a form with a simple series of mouse clicks and dragging motions. A ComboBox displays a text box combined with a ListBox, which enables the user to select items from the list or enter a new value.

The user can type a value in the text field or click the button to display a drop down list. You can add individual objects with the Add method. You can delete items with the Remove method or clear the entire list with the Clear method.
How add a item to combobox
ComboBox SelectedItem
How to retrieve value from ComboBox
If you want to retrieve the displayed item to a string variable , you can code like this
How to remove an item from ComboBox
You can remove items from a combobox in two ways. You can remove item at a the specified index or giving a specified item by name.
The above code will remove the second item from the combobox.
The above code will remove the item «Friday» from the combobox.
DropDownStyle
The DropDownStyle property specifies whether the list is always displayed or whether the list is displayed in a drop-down. The DropDownStyle property also specifies whether the text portion can be edited.

ComboBox Selected Value
How to set the selected item in a comboBox
You can display selected item in a combobox in two ways.
ComboBox DataSource Property
How to populate a combo box with a DataSet ?
You can Programmatically Binding DataSource to ComboBox in a simple way..
Consider an sql string like. «select au_id,au_lname from authors»;
Make a datasource and bind it like the following.
Combobox SelectedIndexChanged event
The SelectedIndexChanged event of a combobox fire when you change the slected item in a combobox. If you want to do something when you change the selection, you can write the program on SelectedIndexChanged event. From the following code you can understand how to set values in the SelectedIndexChanged event of a combobox. Drag and drop two combobox on the Form and copy and paste the following source code.

ComboBox Databinding
You can bind data to a Combobox from various resources like Dataset, List, Enum, Dictionary etc. From the following link you can study more about . ComboBox Databinding
ComboBox Default Value
How to set a default value for a Combo Box
You can set combobox default value by using SelectedIndex property
Above code set 6th item as combobox default value
ComboBox readonly
How to make a combobox read only
You can make a ComboBox readonly, that means a user cannot write in a combo box but he can select the given items, in two ways. By default, DropDownStyle property of a Combobox is DropDown. In this case user can enter values to combobox. When you change the DropDownStyle property to DropDownList, the Combobox will become read only and user can not enter values to combobox. Second method, if you want the combobox completely read only, you can set comboBox1.Enabled = false.
Autocomplete ComboBox
From the latest version of Visual Studio, some of the controls support Autocomplete feature including the ComboBox controls. From the following link you can see how to make . Autocomplete ComboBox
ComboBox Example
The following C# source code add seven days in a week to a combo box while load event of a Windows Form and int Button click event it displays the selected text in the Combo Box.
Get selected value from combo box in C# WPF
I have just started using WPF forms instead of Windows Forms forms. In a Windows Forms form I could just do:
And this would work fine.
How do I do this in WPF? It doesn’t seem to have the option.
![]()
25 Answers 25
I have figured it out a bit of a strange way of doing it compared to the old WF forms:
![]()
Well.. I found a simpler solution.
This way I get the selected value as string.
![]()
My XAML is as below:
The content is showing as text and the name of the WPF combobox. To get the name of the selected item, I have follow this line of code:
To get the selected text of a WPF combobox:
![]()
![]()
Ensure you have set the name for your ComboBox in your XAML file:
In your code you can access selected item using SelectedItem property:
![]()
It depends what you bound to your ComboBox. If you have bound an object called MyObject, and have, let’s say, a property called Name do the following:
How about these:
![]()
As a variant in the ComboBox SelectionChanged event handler:
![]()
I had a similar issue and tried a number of solutions suggested in this thread but found that the SelectionChanged Event was firing before the ComboBox item had actually updated to show the new selection (i.e. so it always gave the contents of the combobox prior to the change occurring).
In order to overcome this, I found that it was better to use the e parameter that is automatically passed to the event handler rather than trying to load the value directly from the combo box.
Solving this problem is simple. All I did was to add «SelectedValuePath» to my XAML code and bind it to my model property that I want to return with the combobox.
![]()
This largely depends on how the box is being filled. If it is done by attaching a DataTable (or other collection) to the ItemsSource , you may find attaching a SelectionChanged event handler to your box in the XAML and then using this in the code-behind useful:
I saw 2 other answers on here that had different parts of that — one had ComboBoxName.Items.GetItemAt(ComboBoxName.SelectedIndex).ToString(); , which looks similar but doesn’t cast the box to a DataRowView , something I found I needed to do, and another: ((DataRowView)comboBox1.SelectedItem).Row.ItemArray[0].ToString(); , used .SelectedItem instead of .Items.GetItemAt(comboBox1.SelectedIndex) . That might’ve worked, but what I settled on was actually the combination of the two I wrote above, and don’t remember why I avoided .SelectedItem except that it must not have worked for me in this scenario.
If you are filling the box dynamically, or with ComboBoxItem items in the dropdown directly in the XAML, this is the code I use:
You’ll see I have cboParser , there. This is because the output from SelectedValue looks like this: System.Windows.Controls.Control: Some Value . At least it did in my project. So you have to parse your Some Value out of that:
But this is why there are so many answers on this page. It largely depends on how you are filling the box, as to how you can get the value back out of it. An answer might be right in one circumstance, and wrong in the other.
Компонент СomboBox
Компонент находится в списке All Windows Forms палитры компонентов. Этот компонент является комбинацией редактируемого поля и списка ListBox : в форме он представляется в виде редактируемого поля с треугольной кнопкой справа. Компонент ComboBox используется для вывода данных в виде выпадающего списка и последующей выборки их из этого списка. По умолчанию ComboBox появляется в виде окна для ввода/вывода текста (аналог однострокового TextBox ), при этом
Глава 11. Компоненты, создающие интерфейс между пользователем и приложением