this is probably really simple,but how do you get the X and Y coordinates when a picturebox is clicked?
Printable View
this is probably really simple,but how do you get the X and Y coordinates when a picturebox is clicked?
Well, I don't know where you want to put the coordiantes(textboxes, labels, etc), but this should work for you.
VB Code:
Private Sub picBox_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles picBox.Click TextBox1.Text = picBox.Location.X TextBox2.Text = picBox.Location.Y End Sub
Actually that will give you the location of the picturebox itself. I think he wants the location of the mouse or click. Try using the MouseDown event instead which will tell you the click, X, Y and some other things from the e argument.
OOoohhh. Sorry. Yeah, I guess you're probably right. That's what I get for being a newbie eager to help other people I guess. Soemtimes I get exited when I think I know the answer, and post too quickly.
thanks, that did it, MouseDown, should have known that.
will this work if the pictue is athumbnail in a series of entries bound to a repater control, say things for sale. Would I need to know which index in the repeater is selected and then use the co-ordinaes above ???
bh
The picturebox in question should be passed as the sender argument and the x,y info will be in the e argument.
thanks edneeis - that makes sense, but with a repater, is there a selected index ?? is this what I would pass
BH
I'm not sure I haven't worked with the repeater but if its an event you shouldn't have to pass anything it should be passed by the control.