Results 1 to 9 of 9

Thread: picturebox click coordinates?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2002
    Posts
    93

    picturebox click coordinates?

    this is probably really simple,but how do you get the X and Y coordinates when a picturebox is clicked?

  2. #2
    Addicted Member The Phoenix's Avatar
    Join Date
    Aug 2003
    Location
    With my wife
    Posts
    142
    Well, I don't know where you want to put the coordiantes(textboxes, labels, etc), but this should work for you.

    VB Code:
    1. Private Sub picBox_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles picBox.Click
    2.         TextBox1.Text = picBox.Location.X
    3.         TextBox2.Text = picBox.Location.Y
    4.     End Sub
    Take my love
    Take my land
    Take me where I cannot stand
    I don't care, I'm still free
    You can't take the sky from me...

  3. #3
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    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.

  4. #4
    Addicted Member The Phoenix's Avatar
    Join Date
    Aug 2003
    Location
    With my wife
    Posts
    142
    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.
    Take my love
    Take my land
    Take me where I cannot stand
    I don't care, I'm still free
    You can't take the sky from me...

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Jul 2002
    Posts
    93
    thanks, that did it, MouseDown, should have known that.

  6. #6
    Addicted Member
    Join Date
    Jun 2002
    Location
    Brisbane Australia
    Posts
    150

    Unhappy location of picture control - repeater

    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

  7. #7
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    The picturebox in question should be passed as the sender argument and the x,y info will be in the e argument.

  8. #8
    Addicted Member
    Join Date
    Jun 2002
    Location
    Brisbane Australia
    Posts
    150

    picture box

    thanks edneeis - that makes sense, but with a repater, is there a selected index ?? is this what I would pass

    BH

  9. #9
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width