Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

vb.net/asp.net onmouseover event?

Status
Not open for further replies.

pabby

IS-IT--Management
Jan 5, 2004
47
GB
HI,

I would like to be able to display peoples photographs when I hover the mouse over the name label and I am not sure of the code. I have been messing around but I am getting the syntax wrong. Any Ideas?

thanks,

 
Labels have some handy events for this, such as MouseHover,MouseEnter,MouseLeave. You'll need to try which one (MouseEnter or MouseHover) suits your purposes better. The MouseEnter event is triggered instantly when the label gets focus (cursor gets to the area), MouseHover has a little latency in contrast to the MouseEnter. This example is with VB.NET assuming that there is a label and picturebox on the form.

Code:
Private Sub Label1_MouseHover(ByVal sender As Object, ByVal e As System.EventArgs) Handles Label1.MouseHover
        PictureBox1.Image = Image.FromFile("D:\picture.jpg")
    End Sub

This is quick and simple if you dont have too many people/images to be shown. If you have lots of names and pictures, you'll want to do the loading of the image by a sub, possibly with labels having the path to the picture in the tag or something like that

I am not able to check the code on asp.net, hope this will help you out.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top