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?
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.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.