日期:2014-05-19  浏览次数:20841 次

ComboBox的奇怪问题,路过有分,在线结贴
SWJGComboBox.DataBindings.Add(new   System.Windows.Forms.Binding( "SelectedValue ",   this.sb_zsxxBindingSource,   "nsr_swjg_dm ",   true));
this.dM_SWJGComboBox.DataSource   =   this.dM_SWJGBindingSource;
this.dM_SWJGComboBox.DisplayMember   =   "SWJG_JC ";
this.dM_SWJGComboBox.DropDownStyle   =   System.Windows.Forms.ComboBoxStyle.DropDownList;
this.dM_SWJGComboBox.ValueMember   =   "SWJG_DM ";

private   void   dM_SWJGComboBox_SelectedIndexChanged(object   sender,   EventArgs   e)
{
                        this.dataSet1.sb_zsxx.Rows[BindingSource1.Position][ "SWJG_MC "]   =   dM_SWJGComboBox.Text;

}

以上为代码,奇怪的是下拉列表只能显示第一项,别的项目显示不出来。
而去掉this.dataSet1.sb_zsxx.Rows[BindingSource1.Position][0]   =   ComboBox1.Text
这句下拉列表就能正常显示,真是太奇怪了,是我的机器有问题,还是这个控件有BUG,还是代码有问题呢?

------解决方案--------------------
SWJG=守卫剑阁?不是吧?
------解决方案--------------------
参考下面的绑定方式.
ComboBox1.DataSource = myDataSet ;//数据集
ComboBox1.DisplayMember = "person.userId " ;//表名加字段名
ComboBox1.ValueMember = "person.username " ;

this.ComboBox1.DataSource = myDataTable;//数据表
this.ComboBox1.DisplayMember = "Name ";//字段名
this.ComboBox1.ValueMember = "userId ";//字段名
------解决方案--------------------
帮顶
------解决方案--------------------
//也许是这样
this.dataSet1.sb_zsxx.Rows[BindingSource1.Position][ "SWJG_MC "] = dM_SWJGComboBox.SelectedItem.ToString();

------解决方案--------------------
路过 帮顶