Is it possible to repaint the form for only one control. That is I need to increase the width of a label. but while repainting the form, the form totally refreshing. that looks like the form is blinking. So I need to redraw the label only. Please help me
Asked
Active
Viewed 2,856 times
2
-
1A simple resize should not cause noticeable flicker, what are you doing exactly? – Alex K. Mar 15 '12 at 12:29
-
I increases thize of a label to work like a progress bar – skmaran.nr.iras Mar 16 '12 at 03:44
2 Answers
3
Instead of formName.Repaint I tried with "DoEvents". It worked for me.
formCreateAndValidate.lblPgrsBar.Width = prgrsLblWidth
DoEvents

skmaran.nr.iras
- 8,152
- 28
- 81
- 116
-
I'm updating a TextBox's DisplayAsHyperlink property on a form's OnCurrent event, and it does not seem to take effect. Calling DoEvents unfortunately does not resolve the issue. I will continue searching for a solution. – StockB Nov 08 '13 at 17:34
2
Instead of Repaint (which is slow indeed) I recommend using this pair of lines to refresh a control:
myControl.Visible = False
myControl.Visible = True
It is much faster. Invisible state is so short that it behaves very smoothly.
It also works for me where DoEvents doesn't. E.g. in a class that has WithEvents attribute to handle control's events and change its appearence. Hope it helps!

hypers
- 1,045
- 1
- 12
- 30