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

GridControl Column Order

Hi,

How to change Columns order (reposition column) in GridControl?

Thanks.

Q

5 Replies

HA haneefm Syncfusion Team June 1, 2007 08:04 PM UTC

Hi Q,

You can apply the this.grid.Model.Cols.MoveRange method to place you columns.To place the first column to the second column, test:

this.gridControl1.Cols.MoveRange(1, 2);

//or

You can allow the user to use the default drag column support by setting AllowDragSelectedCols to true and enable DragColumnHeader flag in the Controller option. Please try this and let me know if this helps.

this.grid.AllowDragSelectedCols = true;
this.grid.ControllerOptions |= GridControllerOptions.DragColumnHeader;

Best regards,
Haneef


QS Qingde Shi June 1, 2007 08:28 PM UTC

Thanks.

What if you only know the column name? I can not find the map from Column Name to Column Index or Index to Name.



>Hi Q,

You can apply the this.grid.Model.Cols.MoveRange method to place you columns.To place the first column to the second column, test:

this.gridControl1.Cols.MoveRange(1, 2);

//or

You can allow the user to use the default drag column support by setting AllowDragSelectedCols to true and enable DragColumnHeader flag in the Controller option. Please try this and let me know if this helps.

this.grid.AllowDragSelectedCols = true;
this.grid.ControllerOptions |= GridControllerOptions.DragColumnHeader;

Best regards,
Haneef


HA haneefm Syncfusion Team June 1, 2007 09:15 PM UTC

Hi Q,

You can find the colIndex by column name using the NameToColIndex method and find the column name by colindex using the ColIndexField method. Here is a code snippet that show this.

int colIndex = grid.Binder.NameToColIndex("ColumnName");

int field = grid.Binder.ColIndexToField(col);
string name = grid.Binder.InternalColumns[field].Name;

Best regards,
Haneef


QS Qingde Shi June 2, 2007 12:39 AM UTC

Hi Haneef ,

Thanks for your help. However, I can not find the Binder property in the GridControl. I am using 4.4.

Q


>Hi Q,

You can find the colIndex by column name using the NameToColIndex method and find the column name by colindex using the ColIndexField method. Here is a code snippet that show this.

int colIndex = grid.Binder.NameToColIndex("ColumnName");

int field = grid.Binder.ColIndexToField(col);
string name = grid.Binder.InternalColumns[field].Name;

Best regards,
Haneef


HA haneefm Syncfusion Team June 4, 2007 09:27 PM UTC

Hi Q,

You can use the GridRangeInfo.GetAlphaLabel() method to get label name from the colindex in a grid. Below is a code snippet

[c#]
Console.WriteLine( GridRangeInfo.GetAlphaLabel(1000) );

Best regards,
Haneef

Loader.
Live Chat Icon For mobile
Up arrow icon