C# 获取repositoryItemGridLookupEdit父项';已处理的当前行
我在该Gridview中有一个Gridview和一个RepositoryItemGridLookUpEdit 我想在RepositoryItemGridLookUpEdit中显示CustomDisplayTextC# 获取repositoryItemGridLookupEdit父项';已处理的当前行,c#,winforms,gridview,devexpress,gridlookupedit,C#,Winforms,Gridview,Devexpress,Gridlookupedit,我在该Gridview中有一个Gridview和一个RepositoryItemGridLookUpEdit 我想在RepositoryItemGridLookUpEdit中显示CustomDisplayText private void rgluePerson_CustomDisplayText(object sender, DevExpress.XtraEditors.Controls.CustomDisplayTextEventArgs e) { v
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;
}
}
问题是人名取决于同一行(在主Gridview中)中的另一个单元格,我不知道如何获取当前正在处理的Gridview行(当前行不工作,因为我现在需要处理该行)。。。。。。我不能使用gridView事件,因为它会更改单元格值,但我想更改文本值。
有人知道怎么做吗?您无法获取由
CustomDisplayText
事件处理的行,因为没有包含当前行的此类字段或属性。您只能对焦点行使用此事件。为此,您必须检查发件人的类型是否为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;
}
对于非焦点行,只能使用事件:
使用GetSelectedRows方法检查在CustomDisplayText事件中是否有正在处理的行尝试gridView3.GetSelectedRows(),但它不会获取事件正在处理的行。Thanx!第二个事件是我一直在寻找的。rgluePerson事件让我有点困惑
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;
}