2009-11-23 47 views
0

任何人都可以解釋,如何簡單地從DevExpress comboBoxEdit Items中的DataTable中輸入值?在WinForms中,它就像這樣:在DevExpress comboBoxEdit Items中輸入來自DataTable的值

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組合框編輯值?

回答

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; 
0

我建議使用LookupEdit控件,而不是與DataSource,DisplayMember和ValueMember屬性一起使用。 ComboBoxEdit控件沒有ItemsSource屬性。