學習記錄
List<string> cmb = new List<string>(); //集合
ComboBox遍歷(一)
for (int i = 0; i < comboBox2.Items.Count; i++)
{
cmb.Add(comboBox2.GetItemText(comboBox2.Items[i]));
}
數據綁定
//cmb.AddRange(new string[]{"中國","朝鮮","朝鮮","日本","法國","美國"}); //為集合賦值
comboBox1.DataSource = cmb; //控件綁定集合
ComboBox遍歷(二) (沒有測試)
foreach (System.Data.DataRowView dr in comboBox1.Items)
{
string id = dr["student_id"].ToString();
string nane = dr["student_name"].ToString();
}