Skip to main content

CustomColumnDisplayTextEventArgs.ListSourceRowIndex Property

Gets the index in the data source of the row which contains the cell currently being processed.

Namespace: DevExpress.XtraGrid.Views.Base

Assembly: DevExpress.XtraGrid.v23.2.dll

NuGet Packages: DevExpress.Win.Grid, DevExpress.Win.Navigation

Declaration

public int ListSourceRowIndex { get; }

Property Value

Type Description
Int32

An integer value representing the row’s index in the data source. Row handles are not data source indexes, see the Accessing Rows in Code. Row Handles section of the “Rows” article for more information.

Remarks

Use the ListSourceRowIndex property to identify the record in the data source that contains the currently processed cell. If this row index refers to a valid row (see below), you can use the ColumnView.GetListSourceRowCellValue method to obtain the row’s other cell values.

This property returns the same value for both Auto Filter and New Item rows. If you need to show custom strings in these rows’ cells, use the GridView.CustomDrawCell event instead.

private void Gv_CustomDrawCell(object sender, XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
{
    if (e.RowHandle == GridControl.AutoFilterRowHandle)
        e.DisplayText = "AutoFilterRow";
    if (e.RowHandle == GridControl.NewItemRowHandle)
        e.DisplayText = "NewItemRow";
}

When the ColumnView.CustomColumnDisplayText event is called to provide cell display text for a group row, the ListSourceRowIndex property will match the data source index of the first data row that follows the group row.

When the ColumnView.CustomColumnDisplayText event is called to customize filter values in a column’s Filter DropDown, the ListSourceRowIndex property returns the GridControl.InvalidRowHandle constant. In this case, it is not possible to determine the currently processed row, and therefore obtain other cell values.

The following code snippets (auto-collected from DevExpress Examples) contain references to the ListSourceRowIndex property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also