get repositoryItemGridLookupEdit parent's currentrow processed

1.4k Views Asked by At

I have a Gridview and a RepositoryItemGridLookUpEdit in that GridView I want to show a CustomDisplayText in the RepositoryItemGridLookUpEdit

private void rgluePerson_CustomDisplayText(object sender, DevExpress.XtraEditors.Controls.CustomDisplayTextEventArgs e)
        {
            var person = rgluePerson.GetRowByKeyValue(e.Value) as Person;
            var name = person.Name;
            var surname = person.Surname;
            e.DisplayText = name + ", " + surname;
            }
        }

The problem is that the person name depends of another cell in the same row (in the main Gridview), and i don't know how to get the current's Gridview row being processed (current row doesn't work since i need the row being processed in the moment)...... i can't use a gridView event cuz it will change the cell value, but i want to change the Text value. Does anyone knows how to do that?

1

There are 1 best solutions below

1
On

You cannot get the row being processed by the CustomDisplayText event because there are no such fields or properties that contains current row. You can only use this event for focused row. For this your must check if sender is type of GridLookUpEdit:

private void rgluePerson_CustomDisplayText(object sender, CustomDisplayTextEventArgs e)
{
    if (!(sender is GridLookUpEdit))
        return;

    var anotherCellValue = gridView1.GetFocusedRowCellValue("AnotherCellFieldName");

    //Your code here

    e.DisplayText = yourDisplayText;        
}

For not focused rows you can use only ColumnView.CustomColumnDisplayText event:

private void gridView1_CustomColumnDisplayText(object sender, CustomColumnDisplayTextEventArgs e)
{
    if (e.Column.ColumnEdit != rgluePerson)
        return;

    var anotherCellValue = gridView1.GetListSourceRowCellValue(e.ListSourceRowIndex, "AnotherCellFieldName");

    //Your code here

    e.DisplayText = yourDisplayText; 
}