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

synch column positions in two identical grids

Please help...again...

I have two grids in my application with identical columns....I want to dynamically change the position of the columns in grid2 when the user changes a column's position in grid1.

so, if the user moves say column "Name" from position 1 to 5 in grid1, I want to dynamically move Column "Name" to position 5 in Grid2


2 Replies

HA haneefm Syncfusion Team May 18, 2007 03:25 AM UTC

Hi Nedu,

To programatically change the column position, you need to use the move method in GridTableDescriptor.VisibleColumns property. If you want to detect the drag column index at runtime then handle the TableControlQueryAllowDragColumn event in a grid. Below is a code snippet that show this.

//For move columns in a grid.
this.grid.TableDescriptor.VisibleColumns.Move(1,2);

private void gridGroupingControl1_TableControlQueryAllowDragColumn(object sender, GridQueryAllowDragColumnEventArgs e)
{
if (e.Reason == GridQueryAllowDragColumnReason.MouseUp)
{
int insertBeforFieldIndex = e.TableControl.TableDescriptor.NameToField(e.InsertBeforeColumn);
int FieldIndex = e.TableControl.TableDescriptor.NameToField(e.Column);
if( FieldIndex < insertBeforFieldIndex )
this.gridGroupingControl2.TableDescriptor.VisibleColumns.Move( FieldIndex, insertBeforFieldIndex - 1);
else
this.gridGroupingControl2.TableDescriptor.VisibleColumns.Move( FieldIndex, insertBeforFieldIndex);
}
}

Please refer to attached sample for implementation and let me know if this helps.
DragFilterBarUserControANDMonthCalendarl.zip

Best regards,
Haneef


CH Chinedu May 18, 2007 03:51 AM UTC

Thank you Haneef, you have been an angel. Thanks a million.

Thanks you so much.

Loader.
Live Chat Icon For mobile
Up arrow icon