Thread: Drag & Drop?

Results 1 to 10 of 10
  1. #1
    guza44_44's Avatar
    Join Date
    Oct 2008
    Gender
    male
    Posts
    433
    Reputation
    16
    Thanks
    310

    Question Drag & Drop?

    Okay i have looked and there are barely any tuts for this that i can find (suprising right?) and also ya i cant get it to work at all and the few tuts there are fail hardcore and none work so do any of you guys have an actual working code for this?
    [IMG]https://i304.photobucke*****m/albums/nn168/guza44/sig-1.png[/IMG]

  2. #2
    XGelite's Avatar
    Join Date
    Mar 2009
    Gender
    male
    Location
    Enter text here
    Posts
    1,344
    Reputation
    12
    Thanks
    276
    one sec...lemme go see if i can make some code for you...

    edit: i did a search on MSDN first and found this - Implementing Drag and Drop in Visual Basic .NET

    Code:
    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
    
    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

    better than i could have done it.




    Thank me if i helped xD
    Last edited by XGelite; 11-10-2009 at 08:37 PM.

  3. #3
    guza44_44's Avatar
    Join Date
    Oct 2008
    Gender
    male
    Posts
    433
    Reputation
    16
    Thanks
    310
    cant get the dang thing to work lol
    [IMG]https://i304.photobucke*****m/albums/nn168/guza44/sig-1.png[/IMG]

  4. #4
    XGelite's Avatar
    Join Date
    Mar 2009
    Gender
    male
    Location
    Enter text here
    Posts
    1,344
    Reputation
    12
    Thanks
    276
    Quote Originally Posted by guza44_44 View Post
    cant get the dang thing to work lol
    what problems are you having with it?

    post your problem and ill help you with it tomorrow 'morning....that is if someone else dont help you with it. its almost 12o clock here and i gotta get up at 5 -.- was long day at work to today... lol
    Last edited by XGelite; 11-10-2009 at 09:00 PM.

  5. #5
    guza44_44's Avatar
    Join Date
    Oct 2008
    Gender
    male
    Posts
    433
    Reputation
    16
    Thanks
    310
    when i try to move an image over it just doesnt show the image when i drop at all...just does nothing thats all the info i have plain and simple, im trying to do this for images and a picturebox
    [IMG]https://i304.photobucke*****m/albums/nn168/guza44/sig-1.png[/IMG]

  6. #6
    XGelite's Avatar
    Join Date
    Mar 2009
    Gender
    male
    Location
    Enter text here
    Posts
    1,344
    Reputation
    12
    Thanks
    276
    Quote Originally Posted by guza44_44 View Post
    when i try to move an image over it just doesnt show the image when i drop at all...just does nothing thats all the info i have plain and simple, im trying to do this for images and a picturebox
    heres code for draggin and dropping a picture
    the previous one was for dragging a text so thats why it didnt work.

    Code:
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As _
    System.EventArgs) Handles MyBase.Load
        ' Enable dropping.
        PictureBox2.AllowDrop = True
    End Sub
    
    Private Sub PictureBox1_MouseDown(ByVal sender As Object, ByVal e As _
    System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown
        If Not PictureBox1.Image Is Nothing Then
            ' Set a flag to show that the mouse is down.
            m_MouseIsDown = True
        End If
    End Sub
    
    Private Sub PictureBox1_MouseMove(ByVal sender As Object, ByVal e As _
    System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseMove
        If m_MouseIsDown Then
            ' Initiate dragging and allow either copy or move.
            PictureBox1.DoDragDrop(PictureBox1.Image, DragDropEffects.Copy Or _
    DragDropEffects.Move)
        End If
        m_MouseIsDown = False
    End Sub
    
    Private Sub PictureBox2_DragEnter(ByVal sender As Object, ByVal e As _
    System.Windows.Forms.DragEventArgs) Handles PictureBox2.DragEnter
        If e.Data.GetDataPresent(DataFormats.Bitmap) Then
            ' Check for the CTRL key. 
            If e.KeyState = 9 Then
                e.Effect = DragDropEffects.Copy
            Else
                e.Effect = DragDropEffects.Move
            End If
        Else
            e.Effect = DragDropEffects.None
        End If
    End Sub
    
    Private Sub PictureBox2_DragDrop(ByVal sender As Object, ByVal e As _
    System.Windows.Forms.DragEventArgs) Handles PictureBox2.DragDrop
        ' Assign the image to the PictureBox.
        PictureBox2.Image = e.Data.GetData(DataFormats.Bitmap)
        ' If the CTRL key is not pressed, delete the source picture.
        If Not e.KeyState = 8 Then
            PictureBox1.Image = Nothing
        End If
    End Sub

  7. The Following User Says Thank You to XGelite For This Useful Post:

    guza44_44 (11-11-2009)

  8. #7
    guza44_44's Avatar
    Join Date
    Oct 2008
    Gender
    male
    Posts
    433
    Reputation
    16
    Thanks
    310
    ya i know i converted it into picture but now it STILL wont work...idk why...thanks though
    [IMG]https://i304.photobucke*****m/albums/nn168/guza44/sig-1.png[/IMG]

  9. #8
    XGelite's Avatar
    Join Date
    Mar 2009
    Gender
    male
    Location
    Enter text here
    Posts
    1,344
    Reputation
    12
    Thanks
    276
    Quote Originally Posted by guza44_44 View Post
    ya i know i converted it into picture but now it STILL wont work...idk why...thanks though
    you do know its got hotkeys right?

  10. #9
    guza44_44's Avatar
    Join Date
    Oct 2008
    Gender
    male
    Posts
    433
    Reputation
    16
    Thanks
    310
    erm......no... -.- i shall try again
    [IMG]https://i304.photobucke*****m/albums/nn168/guza44/sig-1.png[/IMG]

  11. #10
    XGelite's Avatar
    Join Date
    Mar 2009
    Gender
    male
    Location
    Enter text here
    Posts
    1,344
    Reputation
    12
    Thanks
    276
    Quote Originally Posted by guza44_44 View Post
    erm......no... -.- i shall try again
    read what it says on MSDN, that may help you out.

Similar Threads

  1. help with drag and drop
    By asdf12345678 in forum Visual Basic Programming
    Replies: 1
    Last Post: 05-31-2011, 12:21 AM
  2. [Request] cool camo xm8 in drag and drop
    By randomicity2 in forum Combat Arms Mod Request
    Replies: 13
    Last Post: 03-06-2011, 05:42 AM
  3. [Help] Drag-drop images.
    By Jason in forum Visual Basic Programming
    Replies: 4
    Last Post: 05-22-2010, 11:02 AM
  4. Texture Hack (Drag 'n Drop)
    By Ryoku3103 in forum Call of Duty Modern Warfare 2 Help
    Replies: 0
    Last Post: 01-24-2010, 08:57 AM
  5. [Release] Custom Textures (Drag n' Drop)
    By Houston in forum Call of Duty 6 - Modern Warfare 2 (MW2) Hacks
    Replies: 40
    Last Post: 01-19-2010, 09:06 PM

Tags for this Thread