I’m writing a Visual Studio toolbar Add-In that displays the current time.
I have a CommandBar toolbar with a CommandBarButton timeLabel on it (because there’s no label available) and a Timer.
Everytime the Timer-Event hits, I set the caption to the current time.
DateTime t = DateTime.Now;
timeLabel.Caption = String.Format("{0}:{1}:{2}", t.Hour, t.Minute, t.Second);
// force Invalidate/repaint
timeLabel.Visible = !timeLabel.Visible;
timeLabel.Visible = !timeLabel.Visible;
Is there a more elegant way to do an Invalidate()? I feel really uncomfortable with this solution.
Thanks & kind regards
Simon
I found an answer for VS 2010, but this doesn’t seem to work for VS 08 unfortunately.
It updates the whole UI:
IMHO my first solution is more understandable than these 3 lines of code, but this could help in case somebody comes across another problem like I did.