We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

QueryCellStyleInfo, e.TableCellIdentity.RowIndex includes group headers

When I use the QueryCellStyleInfo event, e.TableCellIdentity.RowIndex gives me the row index of the currently evaluated cell in the grid, however this is the row index _including_ group headers.
(For example, my data table has 20 records and gets grouped into three sections, so the total number of rows in the grid is 23.)

When I compare this row index to the collection GridGroupingControl.Table.Records, it does not fit, because GridGroupingControl.Table.Records only iterates through the 20 "real" records of the grid and not through the three group headers.
(I want to know the values in other columns of the same row.)

How, then, can I get row values at other columns given the row index from e.TableCellIdentity.RowIndex?

Thanks a lot,
Anne

1 Reply

AK Adhikesevan Kothandaraman Syncfusion Team September 29, 2015 06:39 AM UTC

Hi Anne,

Thanks for contacting Syncfusion Support.

If you are using the QueryCellInfo event to get the record value, it can be achieved by getting the display element of the current record. The event argument of the QueryCellInfo  has the style object ”e”, we can get the display element by using the e.TableCellIndentity.DisplayElement . Please refer to the following code example,

Code Example:

void gridGroupingControl1_QueryCellStyleInfo(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableCellStyleInfoEventArgs e)

{

    if (e.TableCellIdentity.RowIndex == 20)

    {

        Element el = e.TableCellIdentity.DisplayElement as Element;

        if (el != null && e.TableCellIdentity.TableCellType == Syncfusion.Windows.Forms.Grid.Grouping.GridTableCellType.RecordFieldCell)

        {

            string fieldValue = el.ParentRecord.GetValue("City").ToString();

        }

    }

}


Suggestion 2:


this.gridGroupingControl1.TableControlCellMouseDown += gridGroupingControl1_TableControlCellMouseDown;

//Get the record value using the row index

void gridGroupingControl1_TableControlCellMouseDown(object sender, GridTableControlCellMouseEventArgs e)

{

    GridTableCellStyleInfo style = e.TableControl.GetTableViewStyleInfo(e.Inner.RowIndex, e.Inner.ColIndex);

    Element el = style.TableCellIdentity.DisplayElement;

    if(el != null && el.ParentRecord !=null)

    {

        Record record = el.ParentRecord as Record;

        MessageBox.Show(record.GetValue("City").ToString());

    }

}


Regards,

Adhi


Loader.
Live Chat Icon For mobile
Up arrow icon