• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 238
  • Last Modified:

Two events with one button??? (urgent)

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
0
ab2ae
Asked:
ab2ae
  • 3
  • 2
2 Solutions
 
TimCotteeHead of Software ServicesCommented:
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
0
 
iboutchkineCommented:
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
0
 
ab2aeAuthor 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'
0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

 
ab2aeAuthor 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
0
 
iboutchkineCommented:
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
0
 
ab2aeAuthor 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
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now