Move buttons Dynamically on a Windows Form

  • Thread starter Thread starter Softwaremaker
  • Start date Start date
S

Softwaremaker

Hi fellows,

Juz wondering if anyone could point me to useful links or resources that
explains how to drag and move a button all over a Windows Form ?
 
This code is for drag drop..see it and understand it..
Note: U need to set the autodrag property of textbox....
Private Sub TextBox1_DragDrop(ByVal sender As Object, ByVal e As
System.Windows.Forms.DragEventArgs) Handles TextBox1.DragDrop

TextBox1.Text = e.Data.GetData(DataFormats.Text).ToString()

End Sub

Private Sub Button1_MouseDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles Button1.MouseDown

Button1.DoDragDrop(Button1.Text, DragDropEffects.Copy)

End Sub



Private Sub Button2_MouseDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles Button2.MouseDown

Button2.DoDragDrop(Button2.Text, DragDropEffects.Copy)

End Sub

Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles TextBox1.TextChanged

End Sub

Private Sub TextBox1_DragEnter(ByVal sender As Object, ByVal e As
System.Windows.Forms.DragEventArgs) Handles TextBox1.DragEnter

e.Effect = DragDropEffects.Copy

End Sub

Regards,
NetPointer
 
Thanks Herfried...this is just what the doctor ordered.

Really appreciate it. I have done that before in VB Classic and the way to
implement this in .NET is similar to that of the pre.NET one.

Thanks.

William
 
Thanks NetPointer...this is just what the doctor ordered.

Really appreciate it. I have done that before in VB Classic and the way to
implement this in .NET is similar to that of the pre.NET one.

Thanks.

William

NetPointer said:
This code is for drag drop..see it and understand it..
Note: U need to set the autodrag property of textbox....
Private Sub TextBox1_DragDrop(ByVal sender As Object, ByVal e As
System.Windows.Forms.DragEventArgs) Handles TextBox1.DragDrop

TextBox1.Text = e.Data.GetData(DataFormats.Text).ToString()

End Sub

Private Sub Button1_MouseDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles Button1.MouseDown

Button1.DoDragDrop(Button1.Text, DragDropEffects.Copy)

End Sub



Private Sub Button2_MouseDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles Button2.MouseDown

Button2.DoDragDrop(Button2.Text, DragDropEffects.Copy)

End Sub

Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles TextBox1.TextChanged

End Sub

Private Sub TextBox1_DragEnter(ByVal sender As Object, ByVal e As
System.Windows.Forms.DragEventArgs) Handles TextBox1.DragEnter

e.Effect = DragDropEffects.Copy

End Sub

Regards,
NetPointer

Herfried K. Wagner said:
You will find a sample for moving a control here:
<http://www.mvps.org/dotnet/dotnet/samples/miscsamples/downloads/XmlSerializ
 
Back
Top