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.
Unfortunately, activation email could not send to your email. Please try again.

QueryCellStyleInfo, e.TableCellIdentity.RowIndex includes group headers

Thread ID:

Created:

Updated:

Platform:

Replies:

120622 Sep 28,2015 10:26 AM Sep 29,2015 02:39 AM Windows Forms 1
loading
Tags: GridGroupingControl
Anne
Asked On September 28, 2015 10:26 AM

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

Adhikesevan Kothandaraman [Syncfusion]
Replied On September 29, 2015 02:39 AM

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


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;