C# Get selected item text from combobox

C# Combobox defined with name my_combobox
private System.Windows.Forms.ComboBox my_combobox;

Read the text of the selected combobox item and assign it to string variable, then show it in message box.
string selected_item_text = my_combobox.GetItemText(my_combobox.SelectedItem); MessageBox.Show(selected_item_text);


|
2017/10/18 06:03

c# combobox fill from database

To get only the unique /distinct/ data table records from any database connected to DataSet in C# project and to put them inside combobox.Fill the table adapter with the records from database.
this.myDBTable_TableAdapter.Fill(this.myDB_DataSet.myDBTable);
Create a view containing the database table
DataView view = new DataView(this.myDB_DataSet.myDBTable);

Copy only the distinct records to new data table.
|
2017/10/05 03:18

c# combobox set selected item by item's text

C# Combobox defined with name my_combobox
private System.Windows.Forms.ComboBox my_combobox;

Define string variable with the text of the combobox item that has to be selected. For example, if the combobox items have text values "item_a" "item_b" "item_c" ... and the item which text is "item_b" has to be selected
| |
2017/10/05 02:52
1