我在使用winform,尝试多次获取comboBox选定项的文本,但一直为空,以下是代码:
List<person>op = new List<person>(); op=DAL_O.per();
foreach(person rt in op )
{
comboBox1.DataSource = op;
comboBox1.DisplayMember = "Name_person";
comboBox1.ValueMember = "id_person";
}
}
private void button2_Click(object sender, EventArgs e)
{
Lbl_full_list.Text+=comboBox1.Items[comboBox1.SelectedIndex].ToString();
//or
Lbl_full_list.Text+= comboBox1.Text;
}
也许有人有想法吗?我在Google上搜索了很多结果,但都没有起作用。