0

I have a C# application with a mainform and several custom user controls on it.

When I move the mainform, the user controls keep repainting and they repaint again when I stop moving the mainform.

What can I do to disable this repainting?

Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
jfronner
  • 19
  • 1
  • 2

3 Answers3

2

An answer to this previous question discusses how to use the WM_SETREDRAW Win32 API to suspend and resume drawing. It includes a nice wrapper class; maybe it will help you.

Community
  • 1
  • 1
David Ruttka
  • 14,269
  • 2
  • 44
  • 39
0

If its flickering thats annoying you, you could try and set the DoubleBuffered property on the control to true.

Other than that you could subscribe the forms move event and turn off painting on the child controls in a similar fashion to whats described in this question...

Have a look here

Community
  • 1
  • 1
Craigt
  • 3,418
  • 6
  • 40
  • 56
  • Hmm... The problem is that the control is not painted at all when I do not repaint it when the mainform has moved. What I want: Only redraw child control #1 and leave the others as is (no repaint) when the mainform has moved. – jfronner Feb 15 '11 at 09:33
0

You should not have to forcefully Invalidate() yourself. I assume you are doing some custom painting in the control? Within the constructor after the InitializeComponent(); do you have

    SetStyle(ControlStyles.UserPaint, true);
    SetStyle(ControlStyles.AllPaintingInWmPaint, true);

?

Dennis Smit
  • 1,168
  • 8
  • 12