miga
07-07-2007, 05: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
newimg1.top = 50
newimg1.Left = 100
newimg2.top = 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)
Controls.Add(newimg1)
Controls.Add(newimg2)
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
clickeditem.top = 80
clickedItem.Left = 200
clickedItem.BringToFront()
End If
If clickeditem.tag = "img2" Then
clickeditem.top = 80
clickedItem.Left = 100
clickedItem.BringToFront()
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
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
newimg1.top = 50
newimg1.Left = 100
newimg2.top = 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)
Controls.Add(newimg1)
Controls.Add(newimg2)
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
clickeditem.top = 80
clickedItem.Left = 200
clickedItem.BringToFront()
End If
If clickeditem.tag = "img2" Then
clickeditem.top = 80
clickedItem.Left = 100
clickedItem.BringToFront()
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