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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Access to datasource row in gridGroupingControl1_QueryCellStyleInfo.

Thread ID:

Created:

Updated:

Platform:

Replies:

13950 May 14,2004 02:18 AM UTC May 14,2004 06:00 AM UTC WinForms 3
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On May 14, 2004 02:18 AM UTC

Hello. I am in gridGroupingControl1_QueryCellStyleInfo handler. How can I get datasource row, for which the cell belongs to ? Thank you.

Administrator [Syncfusion]
Replied On May 14, 2004 04:41 AM UTC

You can GridRecord from the e.TableCellIdentity.DisplayElement. From the record, you can get the underlying DataRowView (or what ever object fills the rows in your IList datasource).
if(e.TableCellIdentity.DisplayElement is GridRecordRow)
{
	GridRecordRow row = e.TableCellIdentity.DisplayElement as GridRecordRow;
	if(row != null)
	{
		GridRecord record = row.ParentGroup.Records[0] as GridRecord;
		if(record != null)
		{
			DataRowView drv = record.GetData() as DataRowView;
			Console.WriteLine(e.Style.Text + " " + drv["LastMarket"].ToString() + " " + e.TableCellIdentity.ColIndex.ToString());
		}
	}
}

Administrator [Syncfusion]
Replied On May 14, 2004 05:06 AM UTC

In this example always returned first record in datasource row.ParentGroup.Records[0]. How to get right source row index (for the specified cell)? Thank you.

Administrator [Syncfusion]
Replied On May 14, 2004 06:00 AM UTC

Try working directly with the row instead of its parent.
if(e.TableCellIdentity.ColIndex > 0 && e.TableCellIdentity.RowIndex > 0 &&
	e.TableCellIdentity.DisplayElement is GridRecordRow
	&& e.TableCellIdentity.Column != null) //make sure a column is being requested
{
	GridRecordRow row = e.TableCellIdentity.DisplayElement as GridRecordRow;
	if(row != null)
	{
		DataRowView drv = row.GetData() as DataRowView;
		if(drv != null)
		{
			string name = e.TableCellIdentity.Column.Name;
			Console.WriteLine(e.Style.Text + " " + drv[name].ToString());
		}
	}
}

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.

Warning Icon 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.Close Icon

;