图片框变成空白

发布于 2024-07-09 17:01:43 字数 121 浏览 4 评论 0原文

在 VisualBasic.Net 中,当我激活图片框然后在其上绘制某些内容时,它会绘制然后立即变为空白。 当我重新绘制它时效果很好,但在我第一次绘制它时几乎总是搞砸。 几个不同的程序都发生过这种情况,并且帮助文件没有帮助。

In VisualBasic.Net When I activate a picture box and then draw something on it, it draws and then immediately goes blank. Works fine when I re-draw it, but almost always messes up the first time I draw on it. This has happenned with several different programs, and the help file is no help.

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

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

发布评论

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

评论(6

逆光飞翔i 2024-07-16 17:01:43

尝试设置 DoubleBuffered 属性

http://msdn.microsoft.com/en-us/library/system.windows.forms.control.doublebuffered.aspx

如果不是这样,请提供更多信息。

Try setting the DoubleBuffered property

http://msdn.microsoft.com/en-us/library/system.windows.forms.control.doublebuffered.aspx

If that's not it, please provide more info.

断桥再见 2024-07-16 17:01:43

通常,如果您要在图片框或其他控件上绘制某些内容,则必须接管 OnPaint 事件,并且您负责保留在此事件上绘制的内容。

Usually, if you're drawing something on a picture box or on another control, you have to take over the OnPaint event, and you're responsible of persisting what you draw on this event.

染墨丶若流云 2024-07-16 17:01:43

谢谢安德鲁,但没有帮助。 我正在使用 .Net Framework 1.1,它不提供 DoubleBuffered 属性...它是 2.0 中的新属性。

不确定要提供什么附加信息..代码有 300 行长。 单击按钮时,代码会展开我的表单,使两个图片框可见(一个在另一个顶部(后面一个用于某些图形标签),然后使用一些图形画笔和笔在前面绘制图形框内同时进行一些数据库活动和计算。

Thank you Andrew, but no help. I'm using .Net Framework 1.1, which does not offer the DoubleBuffered property... it was new in 2.0.

Not sure what additional info to provide.. the code is 300 lines long. When a button is clicked, the code expands my form, makes two picture boxes visible (one on top of the other (the back one is for some graph labels), and then uses some graphic brushes and pens to draw a graph on the front box. There's some database activity and calculations going on in the background at the same time.

(り薆情海 2024-07-16 17:01:43

我假设您使用的是标准 PictureBox 组件。 你在Paint-Handler中画画吗? 如果没有,那么下次要求重新绘制自身(擦除背景等)时,PictureBox 只会擦除您绘制的内容。

I assume you're using the standard PictureBox component. Do you draw in the Paint-Handler? If not then the PictureBox will just erase your painted stuff next time it's asked to redraw itself (erase background etc.).

誰認得朕 2024-07-16 17:01:43

是的,我相信我正在使用标准图片框。

通过 Paint-Handler,我假设您指的是 [Control].PaintEvent 处理程序。 不,我没有使用事件处理程序来进行绘图...绘制图表本身并不是一个事件,而是对按钮单击事件的更大响应的一部分。

如果您说让绘图代码成为单独且特定的处理程序的一部分可以解决我的问题,那么我想每次我想重新绘制图表时都可以引发一个内部事件。 但我宁愿弄清楚是什么导致 PB 在没有被告知的情况下重新绘制自己。

Yes, I believe I am using the standard picture box.

By Paint-Handler, I assume you mean a [Control].PaintEvent Handler. No I'm not using an event handler to do the drawing... drawing my chart is not an event in itself, but part of a much larger response to a button click event.

If you are saying that having the drawing code be part of a separate and specific handler can solve my problem, than I guess I could raise an internal event every time I want to redraw the chart. But I Would rather just figure out what is causing the PB to redraw itself without being told to.

咆哮 2024-07-16 17:01:43

如果您无法使用 DoubleBuffered,则可以隐藏第二个图片框。 您可以在其中进行绘图,一旦完成,您就可以返回可见的绘图。 这样,绘图过程就在隐藏的部分完成,并且不会显示白色/闪烁。

If you cannot use the DoubleBuffered than you can HIDE a second picture box. You do the drawing in it and once it's completed you draw back to the VISIBLE one. This way the process of drawing is done on the hidden one and the white/flickering will not be shown.

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