How can I make the BackColor of a Label update faster?

1k views Asked by At

EDIT:

I have managed a workaround. Now on MouseEnter, I set the focus to the button, and I change the MouseOverBackColor to the button's current BackColor; I also have an event handler (in the parent container of the button) for GotFocus that changes the BackColor accordingly. I have NO idea why this works this way but I have only gotten it to work in this particular combination. Again, I am looking for better ways to do it so keep it up with the answers.

I made a Button override and the Text property now overrides to a custom child Label. The problem is I have styles applied to the button (color changing on focus/mouse enter).

I would like the Label to change it's color accordingly and I have achieved this in two ways so far:

  1. Set the label's BackColor to Transparent
  2. Override the OnMouseEnter and OnMouseLeave to also change the Label's BackColor accordingly.

They both work; the only problem is there is a slight delay when changing the BackColor of the Label; this result to a little tearing in graphics when the Button's BackColor changes. This isn't such a big deal but it is a little annoying; would appreciate any useful advice you would bestow upon me.

1

There are 1 answers

1
AudioBubble On BEST ANSWER

depending upon how frequently your application processes the windows message pump or how idle it is, you may need to call Control.Update() to force .NET to update the painting of the control immediately.

http://msdn.microsoft.com/en-us/library/system.windows.forms.control.update.aspx