实体框架 - 将组合框绑定到规范化表字段 [英] Entity Framework - Bind Combobox to Normalised Table Field
本文介绍了实体框架 - 将组合框绑定到规范化表字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我目前正在尝试绑定一个实体到一个窗体,但我想有DataConfidenceLevel(见下文)绑定到一个组合框与ConfidenceDescription作为显示成员。
I am currently trying to bind an entity to a form however I want to have DataConfidenceLevel (see below) bound to a combobox with ConfidenceDescription as the display member. What is the correct way to populate the combobox?
(我目前正在使用WPF,但可以接受Winforms答案)
(I am currently using WPF but a Winforms answer is acceptable)
感谢
实体设计师http://img19.imageshack.us/img19/374/entity.png
推荐答案
答案是
comboBox.DataBindings.Add(new Binding("SelectedItem", this.dataBindingSource, "DataConfidenceLevel", true));
comboBox.DataSource = db.DataConfidenceLevel;
comboBox.DisplayMember = "ConfidenceDescription";
comboBox.ValueMember = "ConfidenceLevelID";
这篇关于实体框架 - 将组合框绑定到规范化表字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文