【发布时间】:2016-10-31 16:45:44
【问题描述】:
我正在尝试将组合框绑定到我使用绑定导航器导航的数据集中的值。
我有一个表单,以及一些通过绑定导航器绑定到数据集的文本框。
绑定到文本框很简单:
this.catActualTextBox.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.myBindingSource, "CatActual", true))
效果很好,但我需要用组合框更改其中一个文本框。文本框显示数字(键),我想显示相关的描述(值)。所以我使用组合框。我用 DataTable 加载组合框,其中有两个列“IdCatActual”(键)和“Descript”(值)。它在表单中正确显示,但导航时不更新:
this.catActualComboBox1.DataSource = myDataTable;
this.catActualComboBox1.DisplayMember = "Descrip";
this.comboBox1.DataBindings.Add(new System.Windows.Forms.Binding("SelectedItem", this.myBindingSource, "CatActual"));
【问题讨论】:
标签: c# data-binding combobox