473,327 Members | 2,065 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

Button change color when mouseover

HS1
Hello all
Do you know how to change color of a button when the mouse is over it (like
a button in manu bar can change its color in a website) in VB.net
Thank you
S.Hoa
Nov 21 '05 #1
2 13360
Hoa,

Have a look at this sample of my it does two buttons, I mostly use it to
show a control array.

I hope this helps?

Cor
\\\needs two buttons and a label on a form
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim btnArea As Button() = New Button() {Button1, Button2}
For Each btn As Button In btnArea
AddHandler btn.MouseLeave, AddressOf Button_MouseLeave
AddHandler btn.MouseEnter, AddressOf Button_MouseEnter
Next
End Sub
Private Sub Button_MouseLeave(ByVal sender As Object, _
ByVal e As System.EventArgs)
DirectCast(sender, Button).BackColor = Color.Black
Me.Label1.Text = ""
End Sub
Private Sub Button_MouseEnter(ByVal sender As Object, _
ByVal e As System.EventArgs)
DirectCast(sender, Button).BackColor = Color.Red
Me.Label1.Text = DirectCast(sender, Button).Name
End Sub
End Class
///
Nov 21 '05 #2
Thanks
That is what I am looking for

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:eA**************@TK2MSFTNGP11.phx.gbl...
Hoa,

Have a look at this sample of my it does two buttons, I mostly use it to
show a control array.

I hope this helps?

Cor
\\\needs two buttons and a label on a form
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim btnArea As Button() = New Button() {Button1, Button2}
For Each btn As Button In btnArea
AddHandler btn.MouseLeave, AddressOf Button_MouseLeave
AddHandler btn.MouseEnter, AddressOf Button_MouseEnter
Next
End Sub
Private Sub Button_MouseLeave(ByVal sender As Object, _
ByVal e As System.EventArgs)
DirectCast(sender, Button).BackColor = Color.Black
Me.Label1.Text = ""
End Sub
Private Sub Button_MouseEnter(ByVal sender As Object, _
ByVal e As System.EventArgs)
DirectCast(sender, Button).BackColor = Color.Red
Me.Label1.Text = DirectCast(sender, Button).Name
End Sub
End Class
///

Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Sugapablo | last post by:
Can anyone help me out with some code to change three table cells (<td>) when one is hovered over? I have a calendar grid where each day is made up of three table cells and I want all three to...
0
by: Panic Student | last post by:
hi all, i'm having trouble with changing image when mouseover on a particular label. Below is what i attempted to but it didn't seem to work at all. I guess my concept is wrong ): Please...
6
by: sr | last post by:
please help i have problem: I know how to change color row in table when my mouse is over on this row and change color to another color when my mouse is out from this row. but i dont know how to...
2
by: fritz21 | last post by:
Hi, if somebody coud help me . It`s a beginner`s question but I`ve tryed to solve it for three days. I have several panels and I need to change their color when the mouse is over them. If...
1
by: lyealain | last post by:
can u pls give me idea on changing the whole row color to become red when one of the column in that row stated the value "false" instead of true
0
by: Reagan | last post by:
Alright i did search in google but can't seem to find it so here goes. How do i get a button to change from the default color to 00FF00 when rolled over any suggestions would be appreciated thanks.
10
by: The Bicycling Guitarist | last post by:
Hello. I have a navigation bar at the top of all my pages with css-styled buttons that change color when hovered over. I am a little confused on how to disable that for the link that the page is...
3
by: nma | last post by:
Hi How do I make the cell change color to 'black' after I click on it. The cell will remain black color until I click another cell which will also change to black. I can do the mouseover and...
1
by: Patrick Shin | last post by:
I'm trying to make a text that keeps on changing color, let say about every 5 seconds. I'm actually new at JavaScript and I can't seem to grasp what needs to be done. The text should keep on changing...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.