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

How do I know which record I''m formatting?

I''m trying to handle the QueryCellStyleInfo event for my GridGroupingControl but I have trouble figuring out which row I''m being queried for. Here''s a code snippet: private void gridGroupingControl1_QueryCellStyleInfo(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableCellStyleInfoEventArgs e) { if ( e.TableCellIdentity.TableCellType == GridTableCellType.AlternateRecordFieldCell || e.TableCellIdentity.TableCellType == GridTableCellType.RecordFieldCell ) { int a0 = e.Style.CellIdentity.CellPos.RowNumber; int a1 = e.Style.CellIdentity.RowIndex; int a2 = e.TableCellIdentity.CellPos.RowNumber; int a3 = e.TableCellIdentity.RowIndex; System.Diagnostics.Debug.WriteLine(String.Format("{0},{1},{2},{3}", a0,a1,a2,a3)); } } Unfortunately, for the first "real" row in my control, this shows me at row #4. How can I reliably compute which of my actual data records corresponds to what I''m looking at???

1 Reply

AD Administrator Syncfusion Team July 13, 2004 04:21 PM

Hi Daniel, try the following code private void gridGroupingControl1_QueryCellStyleInfo(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableCellStyleInfoEventArgs e) { if ( e.TableCellIdentity.TableCellType == GridTableCellType.AlternateRecordFieldCell || e.TableCellIdentity.TableCellType == GridTableCellType.RecordFieldCell ) { Table table = e.TableCellIdentity.DisplayElement.ParentTable; // Get record in table Record record = e.TableCellIdentity.DisplayElement.ParentRecord; int recordInTableIndex = table.Records.IndexOf(record); // - or in group - Group group = e.TableCellIdentity.DisplayElement.ParentGroup; int recordInGroupIndex = group.Records.IndexOf(record); } } Stefan

Loader.
Live Chat Icon For mobile
Up arrow icon