Changing Color of TextBox on Hover - With Correct Examples!!!

H

Henry Jones

I have a VS 2005 VB.NET project and would like to change the color of the
textbox when the user hovers over it. In a Module I have the following
routines:

Public Sub Button_Hover(ByRef btnName As Button)

btnName.BackColor = Color.BlanchedAlmond

End Sub

Public Sub Button_Leave(ByRef btnName As Button)

btnName.BackColor = Color.Transparent

End Sub

----------------------------------------------



I called the routines from the following code:



Private Sub cmdTierCancel_MouseHover(ByVal sender As Object, ByVal e As
System.EventArgs) Handles cmdTierCancel.MouseHover

Button_Hover(cmdTierCancel)

End Sub

Private Sub cmdTierCancel_MouseLeave(ByVal sender As Object, ByVal e As
System.EventArgs) Handles cmdTierCancel.MouseLeave

Button_Leave(cmdTierCancel)

End Sub

---------------------------------

SO FAR SO GOOD. I thought it would be nice to use the Handles feature and
call the routine like this:

---------------------------------

Public Sub Handles_All_Buttons(ByVal sender As Object, ByVal e As
System.EventArgs) Handles cmd1.MouseHover, cmd2.MouseHover,
cmd3.MouseHover

Button_Hover(sender)

End Sub



But this routine doesn't work. Can anyone tell me what I am doing wrong?



Thanks
 
R

RobinS

Check out my response (the one with the code)
to your other posting. I think if you want to
add events, you need to treat the Button_Hover
and Button_Leave routines as events, with
the appropriate arguments. There's an example
in my response to your other thread.

Robin S.
 
R

RobinS

Sorry, I meant you need to treat them as Event Handlers.

Robin S.
---------------------------------
 

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