Omarrrio Omarrrio - 1 year ago 57
C# Question

Changing a Controls Visible Proprety doesn't redraw the Control

i can't get the control visible property to change accordingly to my set value in code, and it looks ugly:

htmlLabel1.Visible = false;
htmlLabel2.Visible = true;
path = s;
if (Path.GetExtension(s) == ".iso")
check = CalculateChecksum(s);

This is what it looks like:
enter image description here

Are there any alternatives to
that i can use to force redraw of the control ? (The control i am using is the HTMLLabel btw)

Answer Source



The Invalidate() method will cause the controls Paint event to fire (forcing the control to be redrawn).

MSDN Ref: Control.Invalidate Method()

Invalidates the entire surface of the control and causes the control to be redrawn.