Home All Groups Group Topic Archive Search About

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

Author
1 Dec 2006 6:21 PM
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

Author
1 Dec 2006 6:32 PM
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.
-------------------------------------
Show quoteHide quote
"Henry Jones" <he***@yada.com> wrote in message
news:ebIXUWXFHHA.4712@TK2MSFTNGP04.phx.gbl...
>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
>
>
>
>
>
>
>
>
>
Author
1 Dec 2006 6:33 PM
RobinS
Sorry, I meant you need to treat them as Event Handlers.

Robin S.
---------------------------------
Show quoteHide quote
"RobinS" <RobinS@NoSpam.yah.none> wrote in message
news:I8-dnRjxSsfO6O3YnZ2dnUVZ_qWdnZ2d@comcast.com...
> 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.
> -------------------------------------
> "Henry Jones" <he***@yada.com> wrote in message
> news:ebIXUWXFHHA.4712@TK2MSFTNGP04.phx.gbl...
>>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
>>
>>
>>
>>
>>
>>
>>
>>
>>
>
>