tags:

views:

997

answers:

1

Hi all How can add a 2-column combobox to Xtragrid which has one col is stored to database and the other is used to display in the xtragrid. Thank so much

+1  A: 

You need to create a RepositoryItemLookUpEdit then set it as your column.ColumnEdit property:

//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();

Sheed