string conString = @"CONNECTION STRING HERE; Password = PWD"; SqlConnection conn = new SqlConnection(conString); DataSet ds = new DataSet(); try { conn.Open(); SqlCommand cmd = new SqlCommand("select * from Devices", conn); SqlDataAdapter da = new SqlDataAdapter(); da.SelectCommand = cmd; da.Fill(ds); comboBox1.DisplayMember = "Address"; comboBox1.ValueMember = "ID"; comboBox1.DataSource = ds.Tables[0]; label7.Text = comboBox1.ValueMember; } catch (Exception ex) { //Exception Message } }
comboBox1.DisplayMember = "Address"; comboBox1.ValueMember = "ID";
label7.Text = comboBox1.SelectedValue.ToString();
Just write down like label7.Text = comboBox1.Text;
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)