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.
Unfortunately, activation email could not send to your email. Please try again.

NameToColIndex method not working

Thread ID:

Created:

Updated:

Platform:

Replies:

67539 Aug 22,2007 08:07 AM Aug 22,2007 01:53 PM Windows Forms 1
loading
Tags: GridControl
Vivek Vashisht
Asked On August 22, 2007 08:07 AM

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.

Rajagopal [Syncfusion]
Replied On August 22, 2007 01:53 PM

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


CONFIRMATION

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.

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.

;