2 Replies - 5611 Views - Last Post: 28 February 2011 - 07:15 AM Rate Topic: -----

#1 mukeshpanth  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 18-January 08

Can i drag textbox value to one form to another form with vb.net

Posted 28 February 2011 - 05:07 AM

Hi,

I am working in vb.net. i want to drag textbox value one form to another form without use show and hide property in the form.
any suggestion

thank 's
mukesh
Is This A Good Question/Topic? 0
  • +

Replies To: Can i drag textbox value to one form to another form with vb.net

#2 Nemesis4895  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 46
  • Joined: 06-December 10

Re: Can i drag textbox value to one form to another form with vb.net

Posted 28 February 2011 - 06:05 AM

Not sure exactly what you mean by dragging the value. But if you mean using the value from another form, then yes.

private sub()
form1.textbox1.text = form2.textbox2.text
end sub


Was This Post Helpful? 0
  • +
  • -

#3 Shadar  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 46
  • View blog
  • Posts: 157
  • Joined: 26-May 09

Re: Can i drag textbox value to one form to another form with vb.net

Posted 28 February 2011 - 07:15 AM

Code for form where text is dragged from.
Public Class frmtemp
    Private MouseIsDown As Boolean = False

    Private Sub TextBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TextBox1.MouseDown
        ' Set a flag to show that the mouse is down.
        MouseIsDown = True
    End Sub

    Private Sub TextBox1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TextBox1.MouseMove
        If MouseIsDown Then
            ' Initiate dragging.
            TextBox1.DoDragDrop(TextBox1.Text, DragDropEffects.Copy)
        End If
        MouseIsDown = False
    End Sub



Code for form to be dragged to.
Change AllowDrop porperty to TRUE for textbox.
    Private Sub TextBox2_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles TextBox2.DragEnter
        ' Check the format of the data being dropped.
        If (e.Data.GetDataPresent(DataFormats.Text)) Then
            ' Display the copy cursor.
            e.Effect = DragDropEffects.Copy
        Else
            ' Display the no-drop cursor.
            e.Effect = DragDropEffects.None
        End If
    End Sub

    Private Sub TextBox2_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles TextBox2.DragDrop
        ' Paste the text.
        TextBox2.Text = e.Data.GetData(DataFormats.Text)
    End Sub

End Class


This post has been edited by Shadar: 28 February 2011 - 07:17 AM

Was This Post Helpful? 1
  • +
  • -

Page 1 of 1