-1

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

htmlLabel1.Visible = false;
htmlLabel1.Update();
htmlLabel2.Visible = true;
htmlLabel2.Update();
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 Update() that i can use to force redraw of the control ? (The control i am using is the HTMLLabel btw)

Jeremy Thompson
  • 61,933
  • 36
  • 195
  • 321
Omarrrio
  • 1,075
  • 1
  • 16
  • 34

1 Answers1

1

Use

htmlLabel2.Invalidate();

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.

Jeremy Thompson
  • 61,933
  • 36
  • 195
  • 321
  • 1
    Nah it does work. just prove it to yourself with [Application.DoEvents](http://stackoverflow.com/questions/5181777/use-of-application-doevents) and never be using that sh*t again. Use a background thread instead. `Invalidate()` does work: see here http://stackoverflow.com/questions/13206926/vb-net-progressbar-backgroundworker – Jeremy Thompson Nov 09 '15 at 13:07
  • Wow i didn't know you had the all seeing eye of rae, when i say it doesn't work, it doesn't work: https://i.gyazo.com/83a2094629c7ae863cc4e1b882039f34.png EDIT: this has nothing to do with a progress bar, nor update progress, i know how to update progress when Hashing a file, the problem at hand, is that in most of my projects i always have to give up on this feature because the `Visible` proprety doesn't work as it should. – Omarrrio Nov 09 '15 at 13:18
  • 1
    OK, maybe there's something I am missing and this is the reason you put a bounty on it, could you please upload a [mcve] for me? – Jeremy Thompson Nov 09 '15 at 13:20
  • I sure hope that pastbin would be enough, i pasted the code to the whole DragDrop event: http://pastebin.com/mFUWxXmM – Omarrrio Nov 09 '15 at 13:26
  • 1
    Well I dare say that an `Application.DoEvents` may just work in a drag/drop operation - though I did disclaim it earlier - can you please try that for us to knuckle down on the root cause, TIA – Jeremy Thompson Nov 09 '15 at 13:30
  • i appologize, i lost internet connexion, third world country problems, Welp, that did it, thank you very much, i'll mark your answer as the right one, please make sure to edit it ^_^ EDIT: i can't award my bounty yet, but in 10 hours i will, thank you again. – Omarrrio Nov 09 '15 at 13:51
  • 1
    No worries mate it's 1am in Australia - I gotta go to bed for work tomorrow, will touch base then, cheers – Jeremy Thompson Nov 09 '15 at 13:54