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.

Access to datasource row in gridGroupingControl1_QueryCellStyleInfo.

Thread ID:

Created:

Updated:

Platform:

Replies:

13950 May 13,2004 10:18 PM May 14,2004 02:00 AM Windows Forms 3
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On May 13, 2004 10:18 PM

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 12:41 AM

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 01:06 AM

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 02:00 AM

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.

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.

;