winform ComBox绑定数据

初始化数据:

List<KeyValuePair<string, string>> list;

ComBox1.ValueMember = "Key";
ComBox1.DisplayMember = "Value";
ComBox1.DataSource = list;

使用:

private void ComBox1_SelectedIndexChanged(object sender, EventArgs e)
{
  string Key= ComBox1.SelectedValue.ToString();
  //todo
}

猜你喜欢

转载自www.cnblogs.com/yaosj/p/10341362.html