在悬停时更改文本框的颜色 [英] Changing Color of Textbox on Hover

查看:59
本文介绍了在悬停时更改文本框的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个VS 2005 VB.NET项目,并希望在用户将鼠标悬停在其上时更改

文本框的颜色。在一个模块中,我有以下

例程:


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


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


我从中调用了例程以下代码:


Private Sub cmdTierCancel_MouseHover(ByVal sender As Object,ByVal e As

System.EventArgs)处理cmdTierCancel.MouseHover


Button_Hover(cmdTierCancel)

End Sub


Private Sub cmdTierCancel_MouseLeave(ByVal sender As Object,ByVal e As

System.EventArgs)处理cmdTierCancel.MouseLeave


Button_Leave(cmdTierCancel)


End Sub


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


SO FAR SO GOOD。我认为使用Handles功能会很好并且

这样调用例程:


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


Public Sub Handles_All_Buttons句柄(ByVal sender As Object,ByVal e As

System.EventArgs)cmd1.MouseHover,cmd2.MouseHover,cmd3.MouseHover


Button_Leave(发件人)


结束Sub


但这个例程不起作用。谁能告诉我我做错了什么?


谢谢


解决方案

< blockquote>在最后一个例程中,Button_Leave应该是Button_Hover

" Henry Jones" <他*** @ yada.com写了留言

新闻:eb ************** @ TK2MSFTNGP02.phx.gbl ...


>我有一个VS 2005 VB.NET项目,并希望在用户将鼠标悬停在其上时更改
文本框的颜色。在一个模块中,我有以下
例程:


Public Sub Button_Hover(ByRef btnName As Button)


bnnName.BackColor = Color.BlanchedAlmond


End Sub


Public Sub Button_Leave(ByRef btnName As Button)


btnName.BackColor = Color.Transparent


End Sub


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


我通过以下代码调用例程:


Private Sub cmdTierCancel_MouseHover(ByVal sender As Object,ByVal e As

System.EventArgs)处理cmdTierCancel.MouseHover


Button_Hover(cmdTierCancel)

End Sub


Private Sub cmdTierCancel_MouseLeave(ByVal发送者为对象,ByVal e As

System.EventArgs)处理cmdTierCancel.MouseLeave


Button_Leave(cmdTierCancel)


结束子


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


SO FA R SO GOOD。我认为使用Handles功能会很好并且

这样调用例程:


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


Public Sub Handles_All_Buttons句柄(ByVal sender As Object,ByVal e As

System.EventArgs)cmd1.MouseHover,cmd2.MouseHover,cmd3.MouseHover


Button_Leave(发件人)


结束Sub


但这个例程不起作用。谁能告诉我我做错了什么?


谢谢




您是否打算从最终的Handles启用例程中调用Button_Hover,

或者这只是一个错字?


- ----

Tim Patrick - www.timaki.com

从头到尾完成Visual Basic 2005


我有一个VS 2005 VB.NET项目,想要改变颜色

当用户将鼠标悬停在文本框上时。在一个模块中,我有以下例程的




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


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


我从中调用了例程以下代码:


Private Sub cmdTierCancel_MouseHover(ByVal sender As Object,ByVal e

As System.EventArgs)处理cmdTierCancel.MouseHover


Button_Hover(cmdTierCancel)

End Sub


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


Button_Leave(cmdTierCancel)


End Sub


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


SO FAR SO GOO D.我认为使用Handles功能

会很好,并按如下方式调用例程:


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


Public Sub Handles_All_Buttons句柄(ByVal sender As Object,ByVal e

As System.EventArgs)cmd1.MouseHover,cmd2.MouseHover,

cmd3.MouseHover


Button_Leave(发送者)

End Sub


但是这个例行程序不起作用。谁能告诉我我在做什么

错了?


谢谢


Henry,


我感兴趣。是什么让你认为使用句柄更好?

.Net方法?


Cor


你想表明你是一名初学程序员还是类似的东西?

" Henry Jones" <他*** @ yada.comschreef在bericht

新闻:eb ************** @ TK2MSFTNGP02.phx.gbl ...


>我有一个VS 2005 VB.NET项目,并希望在用户将鼠标悬停在其上时更改
文本框的颜色。在一个模块中,我有以下
例程:


Public Sub Button_Hover(ByRef btnName As Button)


bnnName.BackColor = Color.BlanchedAlmond


End Sub


Public Sub Button_Leave(ByRef btnName As Button)


btnName.BackColor = Color.Transparent


End Sub


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


我通过以下代码调用例程:


Private Sub cmdTierCancel_MouseHover(ByVal sender As Object,ByVal e As

System.EventArgs)处理cmdTierCancel.MouseHover


Button_Hover(cmdTierCancel)

End Sub


Private Sub cmdTierCancel_MouseLeave(ByVal发送者为对象,ByVal e As

System.EventArgs)处理cmdTierCancel.MouseLeave


Button_Leave(cmdTierCancel)


结束子


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


SO FA R SO GOOD。我认为使用Handles功能会很好并且

这样调用例程:


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


Public Sub Handles_All_Buttons句柄(ByVal sender As Object,ByVal e As

System.EventArgs)cmd1.MouseHover,cmd2.MouseHover,cmd3.MouseHover


Button_Leave(发件人)


结束Sub


但这个例程不起作用。谁能告诉我我做错了什么?


谢谢




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 Handles(ByVal sender As Object, ByVal e As
System.EventArgs) cmd1.MouseHover, cmd2.MouseHover, cmd3.MouseHover

Button_Leave(sender)

End Sub

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

Thanks


解决方案

In the last routine, Button_Leave should be Button_Hover
"Henry Jones" <he***@yada.comwrote in message
news:eb**************@TK2MSFTNGP02.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 Handles(ByVal sender As Object, ByVal e As
System.EventArgs) cmd1.MouseHover, cmd2.MouseHover, cmd3.MouseHover

Button_Leave(sender)

End Sub

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

Thanks





Did you intend to call Button_Hover from your final Handles-enabled routine,
or was that just a typo?

-----
Tim Patrick - www.timaki.com
Start-to-Finish Visual Basic 2005

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 Handles(ByVal sender As Object, ByVal e
As System.EventArgs) cmd1.MouseHover, cmd2.MouseHover,
cmd3.MouseHover

Button_Leave(sender)

End Sub

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

Thanks



Henry,

I am interested. What makes it that you think nicer to use handles instead
of .Net methods?

Cor

You want to show that you are a starting programmer or something like that?
"Henry Jones" <he***@yada.comschreef in bericht
news:eb**************@TK2MSFTNGP02.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 Handles(ByVal sender As Object, ByVal e As
System.EventArgs) cmd1.MouseHover, cmd2.MouseHover, cmd3.MouseHover

Button_Leave(sender)

End Sub

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

Thanks





这篇关于在悬停时更改文本框的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆