我在我的C#表單中有一個組合框。我給它這樣的如何從索引中獲取組合框的值?
string selectSql = "SELECT ID, NAME FROM MUSTERI";
SqlCommand comm = new SqlCommand(selectSql, conn);
SqlDataReader dr = comm.ExecuteReader();
DataTable dt = new DataTable();
dt.Columns.Add("ID", typeof(string));
dt.Columns.Add("NAME", typeof(string));
dt.Load(dr);
combobox.ValueMember = "ID";
combobox.DisplayMember = "AD";
combobox.DataSource = dt;
我可以使用使用Combobox.SelectedText
Combobox.SelectedValue
和項目的文本(其中來自數據庫名)項的值(來自數據庫ID)數據源,但是我需要得到k的值。項目(例如:第4項的值)。我怎麼弄到的?
我在找大約2小時...謝謝 –
不客氣:) – keyboardP