我想设计两对的视觉匹配。将有两列。左边的列有图像,右边的列有单词标签。用户必须将图像拖到正确的标签上。
由于表单大小很小,图像必须更小(缩略图)。因此,当用户将鼠标悬停在图像上时,也应该进行图像放大。用户还应该仍然能够做一个基本的拖放图像.
那么,我该如何实现这两个目标呢?
用于label
发布于 2011-05-05 15:00:44
1)拖放PictureBox到标签:
首先,必须将标签的AllowDrop属性设置为True (也可以在designer中完成):
Label.AllowDrop = True处理PictureBox.MouseDown以激活DragDrop:
Private Sub PictureBox1_Click(ByVal sender As Object, ByVal e As System.EventArgs) _
Handles PictureBox1.MouseDown
PictureBox1.DoDragDrop(PictureBox1, DragDropEffects.All)
End Sub现在,处理标签的DragEnter和DragDrop事件:
Private Sub Label1_DragDrop(ByVal sender As Object, _
ByVal e As System.Windows.Forms.DragEventArgs) Handles Label1.DragDrop
'Get the data being dropped from e.Data and do something.
End Sub
Private Sub Label1_DragEnter(ByVal sender As Object, _
ByVal e As System.Windows.Forms.DragEventArgs) Handles Label1.DragEnter
'e.Effect controls what type of DragDrop operations are allowed on the label.
'You can also check the type of data that is being dropped on the label here
'by checking e.Data.
e.Effect = DragDropEffects.All
End Sub2)扩大PictureBox on MouseOver:
创建一个只包含一个PictureBox的新表单。这是我们将显示的形式,当我们想要显示一个放大的图像,让我们称之为Form2。现在,只需处理缩略图框的MouseHover事件:
Private Sub PictureBox1_MouseHover(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles PictureBox1.MouseHover
'PictureBox1 is the thumbnail on the original form.
'PictureBox2 is the full size image on the popup form.
Form2.PictureBox2.ClientSize = PictureBox1.Image.Size
Form2.PictureBox2.Image = CType(PictureBox1.Image.Clone, Image)
Form2.ShowDialog()
End Sub您需要处理如何处理弹出窗体。
https://stackoverflow.com/questions/5887898
复制相似问题