views:

332

answers:

3

Every time I change the enable disable property of the controls on my winform it repaints the whole form. I want to avoid the redundant repaints by only repainting when i have updated all of the controls. Is this possible?

+2  A: 

There are several good tips in this article on how to take more control over the repainting process.

JP Alioto
A: 

This is a quick hack, but I think you can set the form's Visible property to False, enable/disable all the controls, and then set the form's Visible back to True.

The article JP references covers a number of better approaches.

Update: actually, what language/platform are you using? I just created a quick test app in C#, and setting the enabled/disabled properties does not cause the entire form to be repainted.

MusiGenesis
+3  A: 

Winforms only repaints the invalidated area of controls whose appearance has changed. If your "whole form" is getting repainted you are doing something wrong. Are you drawing anything outside your Paint event handlers? Are you invalidating something in your Paint event handlers? Don't do that.

Please post the code that is causing this problem.

Dour High Arch
"Doctor, it hurts when I do this." "Don't do that."
MusiGenesis