简体   繁体   中英

DevExpress GridView: how to add a LookUpEdit cell

The problem is this: I have a GridView with several columns and I want a few of them to contain LookUpEdit items. I get the same error in all of them so I'll share the easies one:

In this code there should be simply 2 options YES or NO but all I get is the null string value in them.

// Create a DataSet that contain the 2 values NO and YES and their keys
DataTable dsSiNO = new DataTable("dsSiNO");
dsSiNO.Columns.Add("Valor", typeof(Decimal));
dsSiNO.Columns.Add("Tipo");
dsSiNO.Rows.Add(0, @""+MsgResources.GetString("MsgNo"));
dsSiNO.Rows.Add(1, @"" + MsgResources.GetString("MsgYes"));

// Create the LookUpEdit variable and set it's options
DevExpress.XtraEditors.Repository.RepositoryItemLookUpEdit myLookup = new DevExpress.XtraEditors.Repository.RepositoryItemLookUpEdit();
myLookup.ShowHeader = false;
myLookup.ShowFooter = false;
myLookup.DataSource = dsSiNO ;
myLookup.Columns.Add(new DevExpress.XtraEditors.Controls.LookUpColumnInfo("Valor"));
myLookup.Columns.Add(new DevExpress.XtraEditors.Controls.LookUpColumnInfo("Tipo"));
myLookup.DisplayMember = "Tipo";
myLookup.ValueMember = "Valor";

// Finally set the LookUpEdit object to the column
gColNEGOCIO.ColumnEdit = myLookup;

All I get are cells with an "[Empty]" String.

问题出在GridView配置中:OptionsBehavior Editable设置为False!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM