CustomColumnDataEventArgs.ListSourceRowIndex Property

Gets the current row’s index in the data source.

Namespace: DevExpress.XtraGrid.Views.Base

Assembly: DevExpress.XtraGrid.v21.1.dll


public int ListSourceRowIndex { get; }

Property Value

Type Description

An integer value identifying the current 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.


Use the ListSourceRowIndex property to refer to the current row using the methods provided by your data source.

To get values in the row identified by the ListSourceRowIndex property, use the ColumnView.GetListSourceRowCellValue method.

Example 1

In the following example, it is assumed that the Grid Control is bound to a table that contains the “Quantity”, “UnitPrice” and “Discount” columns. The code below adds an unbound column that calculates the total order amount according to the following expression: Quantity*UnitPrice*(1-Discount).


using DevExpress.XtraGrid.Views.Base;
using DevExpress.XtraGrid.Views.Grid;
using DevExpress.XtraGrid.Columns;

private void Form1_Load(object sender, EventArgs e) {
    // ...

    // Create an unbound column.
    GridColumn unboundColumn = gridView1.Columns.AddField("Total");
    unboundColumn.VisibleIndex = gridView1.Columns.Count;
    unboundColumn.UnboundDataType = typeof(decimal);
    // Disable column edit operations.
    unboundColumn.OptionsColumn.AllowEdit = false;
    // Specify format settings.
    unboundColumn.DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric;
    unboundColumn.DisplayFormat.FormatString = "c";
    // Customize the appearance settings.
    unboundColumn.AppearanceCell.BackColor = Color.FromArgb(179, 226, 221);

// Return the total amount for a specific row.
decimal getTotalValue(GridView view, int listSourceRowIndex) {
    decimal unitPrice = Convert.ToDecimal(view.GetListSourceRowCellValue(listSourceRowIndex, "UnitPrice"));
    decimal quantity = Convert.ToDecimal(view.GetListSourceRowCellValue(listSourceRowIndex, "Quantity"));
    decimal discount = Convert.ToDecimal(view.GetListSourceRowCellValue(listSourceRowIndex, "Discount"));
    return unitPrice * quantity * (1 - discount);

// Specify data for the Total column.
private void gridView1_CustomUnboundColumnData(object sender, CustomColumnDataEventArgs e) {
   GridView view = sender as GridView;
   if (e.Column.FieldName == "Total" && e.IsGetData) e.Value = 
     getTotalValue(view, e.ListSourceRowIndex);
See Also