如何将2列组合框添加到Xtragrid,其中一个col存储到数据库,另一个用于在xtragrid中显示。 非常感谢
答案 0 :(得分:1)
您需要创建RepositoryItemLookUpEdit,然后将其设置为column.ColumnEdit属性:
//Set the dropdown values for the cell
RepositoryItemLookUpEdit colCombo = new RepositoryItemLookUpEdit();
colCombo.ShowHeader = true;
colCombo.ShowFooter = false;
colCombo.DataSource = dsRules.YOURTABLE;
colCombo.DisplayMember = "DESCRIPTION";
colCombo.ValueMember = "ID"; //Your DB column
colCombo.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.DisableTextEditor;
colCombo.NullText = "";
//colGRIDCOLUMN is your DevExpress.XtraGrid.Columns.GridColumn
colGRIDCOLUMN.ColumnEdit = colCombo;
LookUpColumnInfoCollection coll = colCombo.Columns;
coll.Add(new LookUpColumnInfo("DESCRIPTION", "DESCRIPTION", 0));
coll.Add(new LookUpColumnInfo("ID", "ID", 0));
colCombo.BestFit();