Simulate drag drop like card games

07-07-2007, 06:35 AM
hi ..
iam having a problem with simulating the card moving like in card games(solitaire ...) ..
what i have until now is when i double click on the card, it moves to the next card, but i want to make it able to be draged by user, and put on the other picturebox

what iam doing is to create 2 picture boxes on runtime :

Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Dim newimg1, newimg2 As New PictureBox

'Add handler to move card on double click

AddHandler newimg1.DoubleClick, AddressOf cimg
AddHandler newimg2.DoubleClick, AddressOf cimg = 50
newimg1.Left = 100 = 50
newimg2.Left = 200
newimg1.Width = 71
newimg1.Width = 71
newimg1.Height = 96
newimg2.Height = 96
newimg1.tag = "img1"
newimg2.tag = "img2"
newimg1.Image = ImageList1.Images(0)
newimg2.Image = ImageList1.Images(1)
End Sub

'and now the function :

Sub cimg(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim clickedItem As PictureBox = DirectCast(sender, PictureBox)

If clickeditem.tag = "img1" Then = 80
clickedItem.Left = 200
End If

If clickeditem.tag = "img2" Then = 80
clickedItem.Left = 100
End If

End Sub
End Class

how can i simulate this using drag and drop like in microsoft card games?
and is there a better way to know items better than using the tag ?
i know the code is not working probably, but iam still optimizing it, i need help on how to simulate the drag thing ..

thanks in advance, and hope someone can help me with my problem

07-07-2007, 01:54 PM
ok never mind,
got it to work ..
thanks anyway

07-07-2007, 07:01 PM
well what was it?

07-16-2007, 12:19 PM
well what was it?

hi, sorry for the late answer :
but i just used the mousedown, mouseup and mousemove events ..
if you are interessted in the code, i can write it , but it is really easy to do ..

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum