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

DragDrop, DragOver and TableControlMouseDown

Hi
how to do to insert into textBox1 or textBox2
the name of the column header gridGroupingControl1.
After dragging the right mouse button to the appropriate textBox1 or textBox2


Attachment: test_ggc007_4b26763d.rar

3 Replies

JP Jagadeesan Pichaimuthu Syncfusion Team July 9, 2019 06:28 AM UTC

Hi Gregory, 
  
Thanks for using Syncfusion product. 
  
To drag and drop the column header text, you could handle the TableControlMouseDown event. Please refer the following code example and the modified sample. 
  
C# 
this.gridGroupingControl1.TableControlMouseDown += gridGroupingControl1_TableControlMouseDown; 
  
void gridGroupingControl1_TableControlMouseDown(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlMouseEventArgs e) 
{ 
    GridGroupingControl grid = sender as GridGroupingControl; 
    if (grid != null) 
    { 
        GridTableControl tableControl = grid.TableControl; 
        Syncfusion.Windows.Forms.Grid.Grouping.GridColumnDescriptor columnDescriptor = gridGroupingControl1.TableControl.GetHeaderColumnDescriptorAt(e.Inner.Location); 
        if (columnDescriptor != null) 
        { 
            rightClickCol = columnDescriptor.HeaderText; 
  
            DragDropEffects ef = tableControl.DoDragDrop(rightClickCol, DragDropEffects.Copy); 
        } 
    } 
} 
  
textBox.AllowDrop = true; 
textBox.DragDrop += TextBox1_DragDrop; 
textBox.DragEnter += TextBox1_DragEnter; 
  
private void TextBox1_DragEnter(object sender, DragEventArgs e) 
{ 
    if (e.Data.GetDataPresent(DataFormats.Text)) e.Effect = DragDropEffects.Copy; 
} 
  
private void TextBox1_DragDrop(object sender, DragEventArgs e) 
{ 
    var data = e.Data.GetData(DataFormats.Text); 
    if(data != null) 
    { 
        (sender as TextBox).Text = data.ToString(); 
    } 
} 
  
                                            
Please get back to us if you need any further assistance on this. 
  
Regards, 
Jagadeesan


GP Gregory Pe replied to Jagadeesan Pichaimuthu July 9, 2019 07:11 AM UTC

Hi Gregory, 
  
Thanks for using Syncfusion product. 
  
To drag and drop the column header text, you could handle the TableControlMouseDown event. Please refer the following code example and the modified sample. 
  
C# 
this.gridGroupingControl1.TableControlMouseDown += gridGroupingControl1_TableControlMouseDown; 
  
void gridGroupingControl1_TableControlMouseDown(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlMouseEventArgs e) 
{ 
    GridGroupingControl grid = sender as GridGroupingControl; 
    if (grid != null) 
    { 
        GridTableControl tableControl = grid.TableControl; 
        Syncfusion.Windows.Forms.Grid.Grouping.GridColumnDescriptor columnDescriptor = gridGroupingControl1.TableControl.GetHeaderColumnDescriptorAt(e.Inner.Location); 
        if (columnDescriptor != null) 
        { 
            rightClickCol = columnDescriptor.HeaderText; 
  
            DragDropEffects ef = tableControl.DoDragDrop(rightClickCol, DragDropEffects.Copy); 
        } 
    } 
} 
  
textBox.AllowDrop = true; 
textBox.DragDrop += TextBox1_DragDrop; 
textBox.DragEnter += TextBox1_DragEnter; 
  
private void TextBox1_DragEnter(object sender, DragEventArgs e) 
{ 
    if (e.Data.GetDataPresent(DataFormats.Text)) e.Effect = DragDropEffects.Copy; 
} 
  
private void TextBox1_DragDrop(object sender, DragEventArgs e) 
{ 
    var data = e.Data.GetData(DataFormats.Text); 
    if(data != null) 
    { 
        (sender as TextBox).Text = data.ToString(); 
    } 
} 
  
                                            
Please get back to us if you need any further assistance on this. 
  
Regards, 
Jagadeesan

Hi Jagadeesan
thank you for the quick reply

Regards, 
Gregory



JP Jagadeesan Pichaimuthu Syncfusion Team July 9, 2019 07:16 AM UTC

Hi Gregory, 
 
Thanks for your update. 
 
Please let us know if you have any further queries on this. We are happy to help you. 
 
Regards, 
Jagadeesan 


Loader.
Live Chat Icon For mobile
Up arrow icon