将DataTable中的值放在DevExpress comboBoxEdit Items中

时间:2009-11-23 09:59:04

标签: wpf combobox datatable devexpress

任何人都可以解释一下,如何在DevExpress comboBoxEdit Items中简单地放置DataTable中的值?在WinForms中它就像这样:

dtCat = SqlHelper.GetTable("base_UserCategory_Select", new string[] {});
DataRow dr = dtCat.NewRow();
dr["UserCategoryID"] = 0;
dr["CategoryName"] = "< All >";
dr["IsSystem"] = "False";
dtCat.Rows.InsertAt(dr, 0);
comboBox1.DataSource = dtCat;

如何将值分配给这样的DevExpress comboBoxEdit?

2 个答案:

答案 0 :(得分:1)

DataTable dtCat = SqlHelper.GetTable("base_UserCategory_Select", new string[] { });
DataRow dr = dtCat.NewRow();
dr["UserCategoryID"] = 0;
dr["CategoryName"] = "< All >";
dtCat.Rows.InsertAt(dr, 0);

comboBoxEdit1.ItemsSource = dtCat.DefaultView;

comboBoxEdit1.SelectedIndex = 1;

答案 1 :(得分:0)

我建议使用LookupEdit控件,结合DataSource,DisplayMember和ValueMember属性。 ComboBoxEdit控件没有ItemsSource属性。