与隐藏和显示 Windows 窗体相关的资源

发布于 2024-10-19 08:13:57 字数 491 浏览 0 评论 0原文

我有一个带有图片框的表单,单击按钮后会出现另一个表单,其中包含包含完全相同图片的图片框。 我使用这行代码:

Image1.Image = vImage.Image

事情是在我这样做之后,我需要隐藏表单并再次显示它以便能够看到更改。我让我对我想避免的用户眨眼,或者做相当于隐藏和显示表单的操作。怎么可能,代码是这样的:

Public Sub UpdatePhoto(ByVal FullName As String, ByVal vImage As System.Windows.Forms.PictureBox)
timAnimate.Enabled = False
Me.Text = FullName
Image1.Image = vImage.Image
Me.Refresh()
Me.Hide()
Me.Show()
Image1.Visible = True
Call ShowTheWindow()

End Sub

I have a form which has a picturebox and after clicking on a button another form will appear with a picture box containing the exact same picture.
I use this line of code:

Image1.Image = vImage.Image

The thing is after I do this i need to hide the form and show it again to be able to see the changes. I cause me a blink for user which I want to avoid or do an equivalent of hiding and showing a form. How is it possible, the code looks like this:

Public Sub UpdatePhoto(ByVal FullName As String, ByVal vImage As System.Windows.Forms.PictureBox)
timAnimate.Enabled = False
Me.Text = FullName
Image1.Image = vImage.Image
Me.Refresh()
Me.Hide()
Me.Show()
Image1.Visible = True
Call ShowTheWindow()

End Sub

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

日久见人心 2024-10-26 08:13:57

我不太明白为什么需要隐藏和显示表单。您只是想刷新表单吗?如果是这样,只需调用:

Application.DoEvents()

或者您可以尝试使您的控件无效:

Image1.Invalidate()

这应该会导致您的表单更新。您不需要再次隐藏和显示。如果这不是您的问题,请更详细地告诉我您的问题是什么。

I'm not quite following why you need to hide and show the form. Are you just trying to get the form to refresh? If so, just call:

Application.DoEvents()

or else you can try invalidating your control:

Image1.Invalidate()

That should cause your form to update. You shouldn't need to hide and show again. If this isn't your issue, let me know in more detail what your problem is.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文