How to make my ''X'' column always be as first column

Hi,

I want to make sure my ''X'' column should be always available at the first position in Grid Grouping Control. The first position of this column should NOT be allowed to Change or occupied by any other column.

Thanks for the help in advance.

Regards
Vijay

1 Reply

AD Administrator Syncfusion Team August 24, 2006 05:19 AM UTC

Hi Vijay,

Use the TableDescriptor.Columns property to manages column descriptors in the grid. It allows you to add and remove columns, moves column at specific position. Below the code snippet.

//Form Load event.
int index = this.gridGroupingControl1.TableDescriptor.NameToField("ColumnName");
this.gridGroupingControl1.TableDescriptor.Columns.Move(index,0);

this.gridGroupingControl1.TableDescriptor.Columns.Changed +=new Syncfusion.Collections.ListPropertyChangedEventHandler(Columns_Changed);

private void Columns_Changed(object sender, Syncfusion.Collections.ListPropertyChangedEventArgs e)
{
if( e.Action == Syncfusion.Collections.ListPropertyChangedType.Move )
{
GridColumnDescriptorCollection columns = sender as GridColumnDescriptorCollection;

if( columns != null && columns[0].Name != "ComboList")
{
columns.Changed -=new Syncfusion.Collections.ListPropertyChangedEventHandler(Columns_Changed);

GridColumnDescriptor col = columns[ "ColumnName" ];
columns.Remove("ColumnName");
columns.Insert(0,col);

columns.Changed +=new Syncfusion.Collections.ListPropertyChangedEventHandler(Columns_Changed);
}
}
}

Here is a sample.
http://www.syncfusion.com/Support/user/uploads/Columns_e2b32cee.zip

Let me know if this is not what you wanted.
Best Regards,
Haneef

Loader.
Up arrow icon