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

NameToColIndex method not working

Hi,
I am using the Grid Control. While populating the grid, I using the code
grid.Model[0,colIndex].Text = "ABC".
When I am trying to access the column Index of ABC by using NameToColIndex method its returning -1 suggesting that the column is not found.
Is there a different way to fill the Model object? Can you please suggest with some code as how should i retieve the column Index by accessing the name of the column?

Thanks
Vivek.

1 Reply

RA Rajagopal Syncfusion Team August 22, 2007 05:53 PM UTC

Hi Vivek,

Thanks for your interest in Syncfusion Products.

The GridControl is a cell oriented grid and not column oriented as GridDataBoundGrid, so the model is not aware of the column names in grid. For more information on the GridControl architecture, check the shipped documentation or the online documentation from the below link.
http://www2.syncfusion.com/library5/index.htm

Here is one way you could do this with GridControl, please try the below code.

private int NameToColIndex(string name)
{
int colIndex = -1;
for( int col = 1; col <= this.gridControl1.Model.ColCount; col++ )
{
if( this.gridControl1[0, col].Text == name )
{
colIndex = col;
break;
}
}
return colIndex;
}

Please refer to the forum thread below for more details.
http://www.syncfusion.com/Support/Forums/message.aspx?MessageID=11801

Let me know if you have any other questions.

Have a nice time.
Regards,
Rajagopal


Loader.
Live Chat Icon For mobile
Up arrow icon