Is it possible Suspend PAINT (not Layout)?

  • Thread starter Thread starter JD
  • Start date Start date
J

JD

I've got a user control that has a number of labels on it. The control has
an UpdateDisplay() method that goes through and sets the .Text property for
those labels based on some calculations. Most of the controls update
quickly, but some of them have slightly more complex calculations. The
effect in the UI is of the control being painted from top to bottom.

I'd like the text to all appear to change at once, even if there is a slight
delay while the calculations happen.

I tried to wrap the UpdateDisplay() code with this.SuspendLayout() and
this.ResumeLayout() -- unfortunately, the docs indicate that this is only
useful for layout-related updates (size, position, dock, anchor).

Is there a way to tell a user control to suspend the painting of itself
while a number of its member controls are updated, and THEN paint them all
at once?

Regards,

JD
 
Honestly JD, this sounds like a control issue to me. If it is that
important why not have you control (i'm assuming custom) do the logic and
prepare their result. A bit of timing and encapsulation if you will.

public class myBox: TextBox
{
object rslt = null;

public myBox()
{}

public void doCalculations()
{
//do complex math
this.rslt = x;
}

public void Show()
{
base.Text = this.rslt;
}
}

That way you can have a routine to call all of the calculations:

public myEventHandler()
{
myBox.doCalculations();
myBox1.doCalculations();
....etc

//then

myBox.Show();
myBox1.Show();
...etc
}

See if this works.

Nick Harris, MCSD
http://www.VizSoft.net
 
JD - I suffered the same type of issue with about 45 different calculated labels. Some changed in milliseconds while others took 2 or three seconds based on calculations. I just created a separate project (you don't have to though) to handle all my calculations and then stored each of the values to a property. Also did all my error validation for / by 0 and nulls. After all calculations were completed, I set the label text based on the property. It loaded instantly this way. Later, I went back and tied in an progress bar and wait cursor for the users.

HTH,
Brian P. Hammer
I've got a user control that has a number of labels on it. The control has
an UpdateDisplay() method that goes through and sets the .Text property for
those labels based on some calculations. Most of the controls update
quickly, but some of them have slightly more complex calculations. The
effect in the UI is of the control being painted from top to bottom.

I'd like the text to all appear to change at once, even if there is a slight
delay while the calculations happen.

I tried to wrap the UpdateDisplay() code with this.SuspendLayout() and
this.ResumeLayout() -- unfortunately, the docs indicate that this is only
useful for layout-related updates (size, position, dock, anchor).

Is there a way to tell a user control to suspend the painting of itself
while a number of its member controls are updated, and THEN paint them all
at once?

Regards,

JD
 
Back
Top