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