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.

synch column positions in two identical grids

Thread ID:

Created:

Updated:

Platform:

Replies:

61126 May 17,2007 09:23 PM May 17,2007 11:51 PM Windows Forms 2
loading
Tags: GridControl
Chinedu
Asked On May 17, 2007 09:23 PM

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


haneefm [Syncfusion]
Replied On May 17, 2007 11:25 PM

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

Chinedu
Replied On May 17, 2007 11:51 PM

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

Thanks you so much.

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.

;