ComboBox.SelectedText doesn't give me the SelectedText

Cocoa Dev picture Cocoa Dev · Apr 17, 2012 · Viewed 109.7k times · Source

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 "

Answer

Marco picture Marco · Apr 17, 2012

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.