|
this.gridGroupingControl1.TableControlMouseDown += gridGroupingControl1_TableControlMouseDown;
this.gridGroupingControl1.DragEnter += GridGroupingControl1_DragEnter;
void gridGroupingControl1_TableControlMouseDown(object sender,GridTableControlMouseEventArgs e)
{
GridGroupingControl grid = sender as GridGroupingControl;
if (grid != null)
{
GridTableControl tableControl = grid.TableControl;
Point pt = new Point(e.Inner.X, e.Inner.Y);
int row, col;
if (tableControl.PointToRowCol(pt, out row, out col))
{
GridTableCellStyleInfo style = tableControl.Model[row, col];
//checks if the cell in which the MouseDown event is a RecordRowHeaderCell.
//If yes, then begins the DragDrop operation.
if(style.TableCellIdentity != null && style.TableCellIdentity.DisplayElement.Kind ==DisplayElementKind.Record)
{
DragDropEffects ef = tableControl.DoDragDrop(style.CellValue.ToString(),DragDropEffects.Copy);
}
}
}
}
private void GridGroupingControl1_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.Text))
{
e.Effect = DragDropEffects.Copy;
}
else
{
e.Effect = DragDropEffects.None;
}
}
|
|
destination_gridGroupingControl1.DragEnter += Destination_gridGroupingControl1_DragEnter;
destination_gridGroupingControl1.DragDrop += Destination_gridGroupingControl1_DragDrop;
private void Destination_gridGroupingControl1_DragDrop(object sender, DragEventArgse)
{
int rowIndex, colIndex;
Syncfusion.Windows.Forms.Grid.Grouping.GridGroupingControl grid = sender asSyncfusion.Windows.Forms.Grid.Grouping.GridGroupingControl;
if (grid != null)
{
grid.TableControl.PointToRowCol(grid.TableControl.PointToClient(new Point(e.X, e.Y)),out rowIndex, out colIndex);
if (rowIndex > 0 && colIndex > 0)
{
GridTableCellStyleInfo style = grid.TableControl.GetTableViewStyleInfo(rowIndex, colIndex);
Element element = style.TableCellIdentity.DisplayElement;
if (element.Kind == DisplayElementKind.Record)
{
Record record = element.GetRecord();
int fieldIndex =this.destination_gridGroupingControl1.TableDescriptor.ColIndexToField(colIndex);
String columnName =this.destination_gridGroupingControl1.TableDescriptor.Columns[fieldIndex].Name;
record.SetValue(columnName, e.Data.GetData(DataFormats.Text));
}
}
}
}
private void Destination_gridGroupingControl1_DragEnter(object sender, DragEventArgse)
{
if (e.Data.GetDataPresent(DataFormats.Text))
{
e.Effect = DragDropEffects.Copy;
}
else
{
e.Effect = DragDropEffects.None;
}
} |
|
this.treeViewAdv1.DragEnter += TreeViewAdv1_DragEnter;
this.treeViewAdv1.DragDrop += new DragEventHandler(treeViewAdv1_DragDrop);
private void TreeViewAdv1_DragEnter(object sender, DragEventArgs e)
{
e.Effect = DragDropEffects.Copy;
}
private void treeViewAdv1_DragDrop(object sender, DragEventArgs e)
{
TreeNodeAdv node = new TreeNodeAdv();
if (e.Data.GetDataPresent(DataFormats.Text))
{
Point pt = ((TreeViewAdv)sender).PointToClient(new Point(e.X, e.Y));
TreeNodeAdv dn = ((TreeViewAdv)sender).GetNodeAtPoint(pt);
node = new TreeNodeAdv(e.Data.GetData(DataFormats.Text).ToString());
dn.Nodes.Add(node.Clone());
dn.Expand();
node.Remove();
}
}
|
Hi Gregory,Query 1 : I need to move the contents of any cell from GGC and source_textBox1 with my mouse from source_gridGroupingControl1 (Form200) and source_textBox1 to destination_gridGroupingControl1 (Form__TreeViewAdv1) to dropped line Columns "drag_and_drop_IN" - to be completedTo DragDrop the GridGroupingControl cell value to other controls, you could use the TableControlMouseDown event to copy the cell value and use DragDop event to get the dropped value the you could set that value to record using SetValue method. Please refer to the below code example,Form200Code example
this.gridGroupingControl1.TableControlMouseDown += gridGroupingControl1_TableControlMouseDown;this.gridGroupingControl1.DragEnter += GridGroupingControl1_DragEnter;void gridGroupingControl1_TableControlMouseDown(object sender,GridTableControlMouseEventArgs e){GridGroupingControl grid = sender as GridGroupingControl;if (grid != null){GridTableControl tableControl = grid.TableControl;Point pt = new Point(e.Inner.X, e.Inner.Y);int row, col;if (tableControl.PointToRowCol(pt, out row, out col)){GridTableCellStyleInfo style = tableControl.Model[row, col];//checks if the cell in which the MouseDown event is a RecordRowHeaderCell.//If yes, then begins the DragDrop operation.if(style.TableCellIdentity != null && style.TableCellIdentity.DisplayElement.Kind ==DisplayElementKind.Record){DragDropEffects ef = tableControl.DoDragDrop(style.CellValue.ToString(),DragDropEffects.Copy);}}}}private void GridGroupingControl1_DragEnter(object sender, DragEventArgs e){if (e.Data.GetDataPresent(DataFormats.Text)){e.Effect = DragDropEffects.Copy;}else{e.Effect = DragDropEffects.None;}}Form_ TreeViewAdv1Code example
destination_gridGroupingControl1.DragEnter += Destination_gridGroupingControl1_DragEnter;destination_gridGroupingControl1.DragDrop += Destination_gridGroupingControl1_DragDrop;private void Destination_gridGroupingControl1_DragDrop(object sender, DragEventArgse){int rowIndex, colIndex;Syncfusion.Windows.Forms.Grid.Grouping.GridGroupingControl grid = sender asSyncfusion.Windows.Forms.Grid.Grouping.GridGroupingControl;if (grid != null){grid.TableControl.PointToRowCol(grid.TableControl.PointToClient(new Point(e.X, e.Y)),out rowIndex, out colIndex);if (rowIndex > 0 && colIndex > 0){GridTableCellStyleInfo style = grid.TableControl.GetTableViewStyleInfo(rowIndex, colIndex);Element element = style.TableCellIdentity.DisplayElement;if (element.Kind == DisplayElementKind.Record){Record record = element.GetRecord();int fieldIndex =this.destination_gridGroupingControl1.TableDescriptor.ColIndexToField(colIndex);String columnName =this.destination_gridGroupingControl1.TableDescriptor.Columns[fieldIndex].Name;record.SetValue(columnName, e.Data.GetData(DataFormats.Text));}}}}private void Destination_gridGroupingControl1_DragEnter(object sender, DragEventArgse){if (e.Data.GetDataPresent(DataFormats.Text)){e.Effect = DragDropEffects.Copy;}else{e.Effect = DragDropEffects.None;}}Query 2 : I need to move the contents of any cell from GGC and source_textBox1 with my mouse from source_gridGroupingControl1 (Form200) and source_textBox1 to treeViewAdv1 (Form__TreeViewAdv1)In order to drag and drop TextBox.Text value to TreeViewAdv control, You should enable AllowDrop property and handle DragEnter and DragDrop event in TreeViewAdv. Please make use of below code snippet.Form_ TreeViewAdv1.cs
this.treeViewAdv1.DragEnter += TreeViewAdv1_DragEnter;this.treeViewAdv1.DragDrop += new DragEventHandler(treeViewAdv1_DragDrop);private void TreeViewAdv1_DragEnter(object sender, DragEventArgs e){e.Effect = DragDropEffects.Copy;}private void treeViewAdv1_DragDrop(object sender, DragEventArgs e){TreeNodeAdv node = new TreeNodeAdv();if (e.Data.GetDataPresent(DataFormats.Text)){Point pt = ((TreeViewAdv)sender).PointToClient(new Point(e.X, e.Y));TreeNodeAdv dn = ((TreeViewAdv)sender).GetNodeAtPoint(pt);node = new TreeNodeAdv(e.Data.GetData(DataFormats.Text).ToString());dn.Nodes.Add(node.Clone());dn.Expand();node.Remove();}}We have modified your sample as per the requirement which can be downloaded from the below location.Please let us know if you require further assistance.Regards,Senthil