Try this:
Suppose your RepositoryItemGridLookUpEdit is bound like this :
repositoryItemGridLookUpEdit1.DisplayMember = "Description";
repositoryItemGridLookUpEdit1.ValueMember = "Id";
// here probably you will use a table from db
repositoryItemGridLookUpEdit1.DataSource = new []
{
new { Id=1, Description = "Normal" },
new { Id=2, Description = "Discount" },
};
then you have your GridControl and set the DataSource like this :
class GridViewDataSource
{
// the id of the description type
public int DescriptionId { get; set; }
}
// again, this probably is taken from db
gridControl2.DataSource = new GridViewDataSource[]
{
new GridViewDataSource { DescriptionId = 1 },
new GridViewDataSource { DescriptionId = 2 },
new GridViewDataSource { DescriptionId = 1 },
new GridViewDataSource { DescriptionId = 2 },
};
Then you have to create CustomUnboundColumnData event
void gridView2_CustomUnboundColumnData(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDataEventArgs e)
{
GridView view = sender as GridView;
if (e.Column.Name == "UnboundColumn" && e.IsGetData)
{
// here you get the Id of the type
var value = (int)view.GetListSourceRowCellValue(e.ListSourceRowIndex, TypeColumn);
// here you get the "Description", for example "Normal" or "Discount"
var text = repositoryItemGridLookUpEdit1.Properties.GetDisplayText(value);
// here you can whatever you want, for example set the text of an unbound column to something
if(text == "Discount")
e.Value = "!!!!";
}
}
Your TypeColumn should have this properties:
this.TypeColumn.Caption = "TypeColumn";
this.TypeColumn.ColumnEdit = this.repositoryItemGridLookUpEdit1;
this.TypeColumn.FieldName = "DescriptionId";
this.TypeColumn.Name = "TypeColumn";
And you UnboundColumn these:
this.UnboundColumn.Caption = "UnboundColumn";
this.UnboundColumn.FieldName = "None";
this.UnboundColumn.Name = "UnboundColumn";
this.UnboundColumn.UnboundType = DevExpress.Data.UnboundColumnType.String;
private void gridView1_CustomUnboundColumnData(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDataEventArgs e) { GridView view = sender as GridView; if (gridView1.Columns["Type"] == gridView1.GetFocusedRowCellValue("Discount")) { if (e.Column.FieldName == "Totalototal" && e.IsGetData) e.Value = getTotalValue(view, e.ListSourceRowIndex); } }- Srihari