开发者

c# databinding combobox change fields

开发者 https://www.devze.com 2022-12-16 06:38 出处:网络
I have databound a DataTable to a combobox, and I have a textbox that is also linked to a field in this same table. The Date field updates as expected when switched between records, but changing the v

I have databound a DataTable to a combobox, and I have a textbox that is also linked to a field in this same table. The Date field updates as expected when switched between records, but changing the value of the Date field causes the list entry in the combobox to change to System.Data.DataRowView. The record still selects fine.

Here is the sample code;

comboBox1.Da开发者_JAVA百科taSource = TblA;
comboBox1.DisplayMember = "ID";

BindingContext binding = this.BindingContext;

BindingManagerBase IDSelected = binding[comboBox1.DataSource];

textBox1.DataBindings.Add("Text",TblA,"Date");


Try using Datasource Update Mode to Never

Binding Constructor (String, Object, String, Boolean, DataSourceUpdateMode)

0

精彩评论

暂无评论...
验证码 换一张
取 消