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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

NameToColIndex method not working

Thread ID:





67539 Aug 22,2007 12:07 PM UTC Aug 22,2007 05:53 PM UTC WinForms 1
Tags: GridControl
Vivek Vashisht
Asked On August 22, 2007 12:07 PM UTC

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?


Rajagopal [Syncfusion]
Replied On 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.

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;
return colIndex;

Please refer to the forum thread below for more details.

Let me know if you have any other questions.

Have a nice time.


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon 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.Close Icon