0

如何向 Xtragrid 添加一个 2 列组合框,其中一个列存储到数据库中,另一个用于在 xtragrid 中显示。非常感谢

4

1 回答 1

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();
于 2009-11-25T14:27:50.813 回答