We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

Two events with one button??? (urgent)

ab2ae
ab2ae asked
on
Medium Priority
251 Views
Last Modified: 2010-04-23
Hi experts,

I need a button to handle two events, a click and mousehover.

I tried the following............

    Private Sub btnShowLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnShowLogin.Click

    Private Sub btnShowLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnShowLogin.MouseHover

.............but a blue line appears underneath btnShowLogin_Click with the following error: "Method 'btnShowLogin_Click' has multiple definitions with identical signatures"

How can a button have two events, i need the same button to respond to a click and mouse hover
Comment
Watch Question

TimCotteeHead of Software Services
Commented:
Hi ab2ae,

  Private Sub btnShowLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnShowLogin.Click,btnShowLogin.MouseHover

You can assign multiple events to the same sub!

Tim Cottee

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
here are the events defrnitions

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    End Sub

    Private Sub Button1_MouseHover(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.MouseHover

    End Sub

Author

Commented:
with the click event i want a textbox to be shown and with a mousehover event i want a label to be shown.

This currently shows both with a mousehover or a click!!

How do i test for which event has been 'fired'

Author

Commented:
just read the post from iboutchkine, two separate events is what i want, prevents any if statements with only one event  having multiple even handlers!!

cheers guys
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
txt.visible = true
label.visible = false
    End Sub

    Private Sub Button1_MouseHover(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.MouseHover
txt.visible = false
label.visible = true
    End Sub

Author

Commented:
Private Sub btnShowLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnShowLogin.Click
       
    Private Sub btnShowLogin_MouseHover(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnShowLogin.MouseHover
     
    End Sub

this is what was i wanted, cheers
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.