其实我需要使用Foreach循环设置组合框的值成员手动设置值Combobox的成员
我的代码是这样的。
foreach(DataRow row in dsTable.Tables["mytable"].Rows)
{
combobox1.Items.Add(row["my column"]);
}
我该如何设置值成员?
其实我需要使用Foreach循环设置组合框的值成员手动设置值Combobox的成员
我的代码是这样的。
foreach(DataRow row in dsTable.Tables["mytable"].Rows)
{
combobox1.Items.Add(row["my column"]);
}
我该如何设置值成员?
您可以添加对象这部分是非常真实的,但这不能帮助OP正面临的问题,由@digEmall解决方案是如何去解决这个问题 – V4Vendetta 2011-03-31 11:47:17
你没有约束DataSource
所以基本上没有意义设置ValueMember
属性。
你应该这样做,而不是循环:
combobox1.DataSource = dsTable.Tables["mytable"];
combobox1.ValueMember = "MyValueColum";
combobox1.DisplayMember = "MyDisplayColumn";
这是不完全清楚你想在这里实现什么。你试图设置哪个'价值'成员?什么? – Skizz 2011-03-31 11:03:00