Search code examples
c#winformsstringcombobox

ComboBox.SelectedText doesn't give me the SelectedText


I am building a String and the code looks like

String status = "The status of my combobox is " + comboBoxTest.SelectedText

I am using WinForm in VS2010

The result looks like

"The status of my combobox is "


Solution

  • I think you want to use

    String status = "The status of my combobox is " + comboBoxTest.Text
    

    SelectedText property from MSDN

    Gets or sets the text that is selected in the editable portion of a ComboBox.

    while Text property from MSDN

    Gets or sets the text associated with this control.