Link to home
Start Free TrialLog in
Avatar of Dov_B
Dov_B

asked on

I need code to make a picture box that I can drag with the mouse at run time and place it on top of another picture box like a rectangle

How can I drag different small graphics with the mouse at run time and overlay it on parts of a larger graphic vb.net 2008 express
ASKER CERTIFIED SOLUTION
Avatar of Deathrace
Deathrace
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Dov_B
Dov_B

ASKER

I tried the first link translated th c# to vb.net and I cant darg a bitmap in a picture box from either panle to the other nothing happens below is the code
 Private Sub panel_DragEnter(ByVal sender As Object, ByVal e As DragEventArgs)
        ' As we are interested in Image data only
        ' we will check this as follows
        If e.Data.GetDataPresent(GetType(Bitmap)) Then
            e.Effect = DragDropEffects.Copy
        Else
            e.Effect = DragDropEffects.None
        End If
    End Sub
    Private Sub panel_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs)
        'we will pass the data that user wants to drag
        'DoDragDrop method is used for holding data
        'DoDragDrop accepts two paramete first paramter 
        'is data(image,file,text etc) and second paramter 
        'specify either user wants to copy the data or move data
 
        Dim source As Panel = DirectCast(sender, Panel)
        DoDragDrop(source.BackgroundImage, DragDropEffects.Copy)
    End Sub
    Private Sub panel_DragDrop(ByVal sender As Object, ByVal e As DragEventArgs)
        'target control will accept data here 
        Dim destination As Panel = DirectCast(sender, Panel)
        destination.BackgroundImage = DirectCast(e.Data.GetData(GetType(Bitmap)), Bitmap)
    End Sub

Open in new window

Did you download the source code, and executed the code.
Avatar of Dov_B

ASKER

Sorry took so long to answer my laptops battery went out on me
anyway I cannot download the project because I dont have c sahrp I only have vb.net 2008 express
and I only know how to paste code into one of those web translating sites
however to me I think I need the second link for my purposes
Avatar of Dov_B

ASKER

dear deatthrace the projects are in c#
Avatar of Dov_B

ASKER

I only have vb.net 2008 express not c#