Problem with TabAlignment and button mouse enter/leave events

G

Guest

Hello,

I encountered a strange problem and I do not know what is causing it.

I created an empty form, added a tabs control to it and set the tab control
dock style to fill. Then I added three tabpages to it. To the first tab page
I added three buttons. The first button's click handler would set the tab
control's tab alignment to TabAlignment.Left and the second buttons click
handler would set it to Bottom.

I added mouse enter and mouse leave handlers to the third button. Whenever
the mouse would enter the button, I would change its background color to
yellow. When the mouse leaves the button, I would set the color back to its
original state.

Now, when I start the form, the mouse enter/leave events work great and
everything is fine. However, once I change the tabs alignment by hitting one
of the first two buttons, the third button no longer fires it's mouse leave
event and only fires the mouse enter event once. The mouse enters and mouse
enter fires correctly, but it seems that the mouse leave event has been
unregistered when the tab control's tab alignment changed.

Does anyone know what can be causing this behavior?

Thanks,
-Flack
 
M

Mick Doherty

It's a problem with any standard .net control and happens when the controls
Container is assigned a new handle.
Changing the TabAlignment cuases the TabControl to be destroyed and
recreated, resulting in a new handle.

You'll probably be better off coding in the MouseMove method of the button
and it's container.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top