3

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?

George
  • 85
  • 1
  • 1
  • 7

1 Answers1

2

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();
Jalal Said
  • 15,906
  • 7
  • 45
  • 68
  • thank you Jalal. this was helpful. I have another problem, I cant minimize the window while the button_click function working. there is something I can do to solve it? – George Jul 16 '11 at 00:49
  • @George: Ask a second stand alone question, then. They're different issues and will have different solutions. – Merlyn Morgan-Graham Jul 16 '11 at 01:02
  • @George: better way is to run the code at your button in another thread so it will not block the UI. – Jalal Said Jul 16 '11 at 01:06
  • please notice that I posted the question at http://stackoverflow.com/questions/6714602/cant-minimize-the-window-while-the-button-click-function-working. there is a solution that not involves threads? – George Jul 16 '11 at 01:08
  • @George: check [this](http://stackoverflow.com/questions/6423606/how-to-lock-the-application-gui-in-c-winform/6424742#6424742) answer. – Jalal Said Jul 16 '11 at 01:09
  • @George: in the left corner near the answer, there is a correct sign. click on it so it will converted to green and that answer then will be come the correct answer to your question. also consider checking [faq](http://stackoverflow.com/faq) – Jalal Said Jul 16 '11 at 01:41