How to add a dropdown list of 2 columns to XtraGrid

How can I add a 2 column combobox to Xtragrid where one col is stored in the database and the other is used to display in the xtragrid. Many thanks

0


a source to share


1 answer


You need to create a RepositoryItemLookUpEdit and then set it as the 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();

      

+1


a source







All Articles