Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c#

winforms

I have a program I wrote in C# with a window that contain a groupBox with image.

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();).

Does there is a way that I can refresh the window without refreshing the groupBox?

*I have another problem, I cant minimize the window while the button_click function working. there is something I can do to solve it?

like image 272
George Avatar asked Dec 21 '25 05:12

George


1 Answers

Use Invalidate() instead of Refresh()

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

Edit: 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

so:

this.Invalidate(false);
this.Update();
like image 103
Jalal Said Avatar answered Dec 23 '25 20:12

Jalal Said



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!