Infragistics.NetAdvantage.WinForm.2012.v2 ComboBoxEditor的小Bug

环境:VS2012 / Win7 / C# Winform / .net 4.0 / 实体集 / DataRow -> BindingSource

问题1:详情:

1.存在一个DataTable,从里面获取一个NewRow。

2.这个NewRow是实体集的实体,在初始化后,给它的属性(外键的属性)赋值。

3.DataTable绑定到BindingSource

4.用ComboBoxEditor,通过把Text属性与BindingSource绑定,来把这个外键属性显示出来。绑定代码写在Form的Shown事件里。

5.当Form打开后,ComboBoxEditor的输入框为空白,”Text“属性为空字符串,也就是无法把值显示出来。

6.把该BindingSource绑定到其他控件的值,做一个修改,然后执行BindingSource.EndEdit(),此时ComboBoxEditor才把值显示出来。

   或者是,先把ComboBoxEditor绑定BindingSource,然后再把C#自带的ComboBox绑定BindingSource的相同属性,则ComboBoxEditor可以直接显示出来。

7.C#自带的ComboBox没有这个问题。但考虑到ComboBoxEditor的外观好看些,所以我还是打算继续用这个控件。

 

 

问题2:不要在UltraGridRowEditTemplate上用UltraComboEditor来绑定UltraGridRowEditTemplate,因为会发生很多小问题。如果一定要用ComboBox控件,可以用C#自带的ComboBox代替。如果使用ComboBox代替后,要注意两个地方:

1.ComboBox的DataBindings绑定的是UltraGridRowEditTemplate而不是数据源的BindingSource。

2.如果要在ComboBox修改后立即提交生效,需要再ComboBox的SelectedIndexChanged事件中,写一行代码:

UltraGridRowEditTemplate.CommitChanges();

 

 

posted on 2013-02-02 23:49  xxxteam  阅读(459)  评论(0编辑  收藏  举报

导航