Accessing current record using OnDraw ''rowIndex''

Hi,
I am using a class that inherits from GridGenericControlCellRenderer. Within the OnDraw method, I am given the 'rowIndex'. When I have only one row in my DataTable datasource, I would expect the rowIndex to be 0 for the first row, but instead it is 1. I assume that it is because the hidden ColumnHeader has rowIndex 0.

So how do I use this rowIndex to obtain the current record? And how can I get the DataRow that the current record will be bound to?

Please note, that I am NOT prepared to accept an answer that includes accessing a row using 'rowIndex - 1'!

Thanks,
Russell

3 Replies

AD Administrator Syncfusion Team May 10, 2007 04:28 PM UTC

If you are using a GridDataBoundGrid as your bound grid, then you can use:

int position = gridDataBoundGrid.Binder.RowIndexToPosition(rowIndex);


RC Russell Coombes May 11, 2007 06:30 AM UTC

I am using the GridGroupingControl, so I'm afraid this won't help me.

Do you have the equivalent code that will work with the GridGroupingControl?

Thanks,
Russell

>If you are using a GridDataBoundGrid as your bound grid, then you can use:

int position = gridDataBoundGrid.Binder.RowIndexToPosition(rowIndex);


AD Administrator Syncfusion Team May 11, 2007 11:25 AM UTC

In a GridGroupingControl, you can access the underlying record through the style object.

GridTableCellStyleInfo tableStyle = style as GridTableCellStyleInfo;
Record r = tableStyle.TableCellIdentity.DisplayElement.GetRecord();
if (r != null)
{
//use code like this to access the field values
object o = r.GetValue("SomeFieldName");
}

Loader.
Up arrow icon