开发者

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

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 Labe开发者_如何学运维l; 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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜