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
close icon

exception when writing to a grid cell

Hello,

I am having a problem when writing to the row header when I use the following line of code:
" this._grid[i, 0].CellValue = rowCount.ToString(); "

I'm simply trying to programmaticaly enumerate this column(0) with a number. But when I make a call to the CellValue, my rowIndex is returned as out of range and an exception is thrown.

i = 2
grid.RowCount = 8

Is there a reason why my grid is upset with accessing this row?

Thanks in advance.


3 Replies

NA Nisha Arockiya A Syncfusion Team November 11, 2008 06:46 AM UTC

You can try handling the PrepareViewStyleInfo event of the grid to get numbered row headers.


private void gridControl1_PrepareViewStyleInfo(object sender, GridPrepareViewStyleInfoEventArgs e)
{
if (e.ColIndex == 0 && e.RowIndex > 0)
{
e.Style.Text = e.RowIndex.ToString();
e.Style.BaseStyle = "Header";
e.Style.Font.Bold = false;
}
}

Here is a small sample for reference.
http://websamples.syncfusion.com//samples/Grid.Windows/GC_RowHeaderNumbering_F77628/main.htm

Please let me know if this serve your needs.

Regards,
Nisha






AC Andy Chan November 11, 2008 01:38 PM UTC

Nisha,

Thanks for the reply. I'm building a grid which populates with vector data. Vector data is not always a 1:1 association so numbering row columns this way is not ideal. I have a separate method in which the code above is throwing an exception... the debug window I have says that it's a Syncfusion ... SetItem() method that is throwing an error.

Any Ideas?



NA Nisha Arockiya A Syncfusion Team November 13, 2008 01:06 PM UTC

Hi Andy,

Thanks for your Updates.

Could you please provide the exception details or the stack, so that it will be very halpful for us to direct you to the exact solution on time?? We appreciate your patience.

Regards,
Nisha


Loader.
Live Chat Icon For mobile
Up arrow icon