0
votes

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.

1
It is necessary to add the RepositoryItemGridLookUpEdit instance to the GridControl.RepositoryItems collection. Otherwise, the GridControl will not activate the RepositoryItemGridLookUpEdit's datasource. Your code can be as follows: DevExpress.XtraEditors.Repository.RepositoryItemLookUpEdit myLookup = (DevExpress.XtraEditors.Repository.RepositoryItemLookUpEdit)gColNEGOCIO.GridControl.RepositoryItems.Add("LookUpEdit"); - Uranus
@Uranus Your code won't work, it says gColNEGOCIO has no property GridControl - Joan.bdm
I apologize. If the gColNEGOCIO is a GridColumn, then you can access the GridControl as follows: gColNEGOCIO.View.GridControl. In any case, the code snippet was just for the illustration. Most probably, you are using Visual Studio designer and have a variable referencing your GridControl. Just use it. - Uranus
Thank you very much for your help Uranus but I already spotted my problem: the GridView had the OptionsBehavior Editable set to False ... - Joan.bdm

1 Answers

0
votes

The problem was in the GridView configuration: the OptionsBehavior Editable was set to False!!!