c# - 如何在不刷新 C# 窗口图像的情况下刷新窗口?

标签 c# winforms

我有一个用 C# 编写的程序,它有一个窗口,其中包含一个带图像的 groupBox。

我有一个按钮可以做一些事情(具体做什么并不重要),它会在他的循环中刷新窗口(在 button_click 函数中)(使用 this.Refresh();)。

有没有一种方法可以在不刷新 groupBox 的情况下刷新窗口?

*我有另一个问题,我无法在 button_click 功能工作时最小化窗口。有什么办法可以解决吗?

最佳答案

使用Invalidate()而不是 Refresh()

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

编辑: msdn

Calling the Invalidate method does not force a synchronous paint; to force a synchronous paint, call the Update method after calling the Invalidate method

所以:

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

关于c# - 如何在不刷新 C# 窗口图像的情况下刷新窗口?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6714501/

相关文章:

c# - 不要在选中的子项上关闭 ToolStripDropDownButton

c# - 调用 MessageBox 和 BeginInvoking 有什么区别?

c# - 基于 Windows 8 XAML 的游戏中的键盘处理

c# - 如何执行作为资源嵌入的可执行文件

c# - 为什么 C# 中的 1 && 2 是假的?

C# : return dbnull. 值或函数的 system.type?

c# - 如何访问 SerialPort.Flush() 和 SerialPort.Finalize() 函数

c# - 防止控件在禁用时变灰

c# - 为什么这个查询返回-1?

c# - 如何检测 C# LINQ 查询中没有返回数据