简体   繁体   English

如何在不刷新 C# 中 window 的图像的情况下刷新 window?

[英]how to refresh a window without refreshing the images of the window in C#?

I have a program I wrote in C# with a window that contain a groupBox with image.我有一个我在 C# 中编写的程序,其中包含一个带有图像的 groupBox 的 window。

I have a button that do some things (it doesn't matter what exactly) and it refresh the window in his loop (in button_click function) (with this.Refresh();).我有一个按钮可以做一些事情(具体是什么并不重要),它会在他的循环中刷新 window(在 button_click 函数中)(使用 this.Refresh();)。

Does there is a way that I can refresh the window without refreshing the groupBox?有没有一种方法可以在不刷新 groupBox 的情况下刷新 window?

*I have another problem, I cant minimize the window while the button_click function working. *我还有另一个问题,我无法在 button_click function 工作时最小化 window。 there is something I can do to solve it?我可以做些什么来解决它?

Use Invalidate() instead of Refresh()使用Invalidate()而不是Refresh()

this.Invalidate(false);//false to not redraw the controls in the form.

Edit: msdn编辑: msdn

Calling the Invalidate method does not force a synchronous paint;调用 Invalidate 方法不会强制同步绘制; to force a synchronous paint, call the Update method after calling the Invalidate method要强制同步绘制,请在调用 Invalidate 方法后调用 Update 方法

so:所以:

this.Invalidate(false);
this.Update();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM