首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在vb.net中放大图片框中的图像

问如何在vb.net中放大图片框中的图像
EN

Stack Overflow用户
提问于 2011-05-04 18:07:00
回答 1查看 3K关注 0票数 0

我想设计两对的视觉匹配。将有两列。左边的列有图像,右边的列有单词标签。用户必须将图像拖到正确的标签上。

由于表单大小很小,图像必须更小(缩略图)。因此,当用户将鼠标悬停在图像上时,也应该进行图像放大。用户还应该仍然能够做一个基本的拖放图像.

那么,我该如何实现这两个目标呢?

用于label

  • Picturebox图像放大的
  1. 拖放图片框?
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-05-05 15:00:44

1)拖放PictureBox到标签:

首先,必须将标签的AllowDrop属性设置为True (也可以在designer中完成):

代码语言:javascript
复制
Label.AllowDrop = True

处理PictureBox.MouseDown以激活DragDrop:

代码语言:javascript
复制
 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事件:

代码语言:javascript
复制
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 Sub

2)扩大PictureBox on MouseOver:

创建一个只包含一个PictureBox的新表单。这是我们将显示的形式,当我们想要显示一个放大的图像,让我们称之为Form2。现在,只需处理缩略图框的MouseHover事件:

代码语言:javascript
复制
 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

您需要处理如何处理弹出窗体。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5887898

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档