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

Get Column Index of GridGroupingControl when GroupingBy a different Column

Thread ID:





103015 Mar 22,2012 09:44 PM UTC Apr 12,2016 08:57 AM UTC WinForms 5
Tags: GridControl
Eric Robishaw
Asked On March 22, 2012 09:44 PM UTC

I need to find the column index of a column in a GridGroupingControl WHEN it is grouped by a column other than the one I'm looking for.

I need to find it DURING: Grid_TableControlCurrentCellValidating()

I.e., my datasource has 4 columns:

If the user has grouped by B

I need to find the index of "D" if I do not know whether it is "D" or "d" (case)

The following works IF and ONLY IF there is NO grouping:

int colIndex = FindColumnIndex(grid.TableDescriptor.VisibleColumns, "d")

private int FindColumnIndex (GridVisibleColumnDescriptorCollection visibleColumns, string columnName)
int index = 1; //one based column indexes
columnName = columnName.ToLower();
foreach (GridVisibleColumnDescriptor col in visibleColumns)
if (col.Name.ToLower() == columnName)
return index;
return -1;

HOWEVER, whenever a user has grouped columns, the above code returns the wrong index.

For example:

grid.Model[grid.CurrentCell.RowIndex, colIndex].CellValue

This returns the value for the Column BEFORE the one I need, WHEN a field is grouped.

I have tried using the TableDescriptor.Columns collection instead of the VisibleColumns collection, but it's no better.


Asarudheen S [Syncfusion]
Replied On April 1, 2012 06:23 PM UTC

Hi Eric,

Thank you for your interest in Syncfusion products.

We are unable to reproduce the reported issue from our side. As a suggestion please make use of following code to resolve the issue.

int index= this.gridGroupingControl1.TableDescriptor.VisibleColumns.IndexOf(columname);

Could you please send us simple sample to replicate your issue so that it will more helpful to update you the exact solution?


Eric Robishaw
Replied On April 2, 2012 03:24 AM UTC

VisibleColumns.IndexOf(columname) only works if you have the exact case of the columnname...

But for various reasons, I do not always know the exact case of the column name, it could be Dog, DOG, or dog...

Ragamathulla B [Syncfusion]
Replied On April 10, 2012 04:55 AM UTC

Hi Eric,

Thanks for the update.

You can get 'Column Index' of GridGroupingControl by using the following code.

//way 1
//way2 this.gridGroupingControl1.TableDescriptor.ColIndexToField(colindex);

Let me know if you have any further concerns.

Ragamathullah B.

QLT User
Replied On April 12, 2016 12:09 AM UTC

does this actually work ?

i think it takes an int and not a string. i would like to get the index from the columnname

Piruthiviraj Malaimelraj [Syncfusion]
Replied On April 12, 2016 08:57 AM UTC

Hi QLT user,

Thank you for your interest in Syncfusion products.

The column collection is maintained in the TableDescriptor.Columns and TableDescriptor.VisibleColumns. In order to get the column index from column name , you can make use of IndexOf method of VisibleColumns or Columns. Please make use of below code and refer to the sample.

Code snippet

int index = this.gridGroupingControl1.TableDescriptor.VisibleColumns.IndexOf("ColumnName");

int id = this.gridGroupingControl1.TableDescriptor.Columns.IndexOf("ColumnName");






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

or the page will be automatically redirected to 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