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

Drag and Drop Multiple Columns in GGC

Can someone please tell me know to drag and drop multiple columns in GGC?

I wrote some custom code in TableControl_MouseDown to do column selection. Now I have multiple columns selected. How can I drag and drop these columns to a different location?

Thanks,

Frankie

1 Reply

AD Administrator Syncfusion Team October 17, 2006 05:58 AM UTC

Hi Frankie,

You can handle the TableControl.QueryAllowDragColumn todrag and drop multiple columns in Grid. Please refer to the attached sample for more details.

private void TableControl_QueryAllowDragColumn(object sender, GridQueryAllowDragColumnEventArgs e)
{
if(e.Reason == GridQueryAllowDragColumnReason.MouseUp)
{
e.AllowDrag = false;

ArrayList SelectedColumnNames = new ArrayList();
int insertBeforeIndex = e.TableControl.TableDescriptor.VisibleColumns.IndexOf(e.InsertBeforeColumn);

if( insertBeforeIndex != -1)
{
foreach(GridRangeInfo columnRange in e.TableControl.Model.SelectedRanges )
{
for(int i = columnRange.Left;i<= columnRange.Right ;i++)
{
int fieldIndex = e.TableControl.TableDescriptor.ColIndexToField(i);
SelectedColumnNames.Add( e.TableControl.TableDescriptor.VisibleColumns[fieldIndex].Name);
}
}
for(int i = 0;i< SelectedColumnNames.Count;i++)
{
int sourceIndex = e.TableControl.TableDescriptor.VisibleColumns.IndexOf(SelectedColumnNames[i].ToString() );
if( sourceIndex != -1)
{
e.TableControl.TableDescriptor.VisibleColumns.Move(sourceIndex,insertBeforeIndex - i);
}
}
}
}
}

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

If this did not help you to solve the problem, please modify the sample to show the problem.

Best Regards,
Haneef

Loader.
Live Chat Icon For mobile
Up arrow icon