daquoc
daquoc

Reputation:

How to add a 2-column combobox to XtraGrid

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

Upvotes: 0

Views: 4528

Answers (1)

Sheed
Sheed

Reputation: 113

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

Upvotes: 1

Related Questions