Results 1 to 10 of 10

Thread: Find Co-Ordinates of selected cell in a grid

  1. #1

    Thread Starter
    Frenzied Member TheBionicOrange's Avatar
    Join Date
    Apr 2001
    Location
    Cardiff, UK
    Posts
    1,818

    Question Find Co-Ordinates of selected cell in a grid

    I have a grid where the cells in the last column are editable.

    When the user selects a cell in the end column I call up a small form, where they input a date.
    What I want to do is have the form appear directly over the active cell.

    Obviously the active cell could be anywhere on a vertical plane within the constraints of the grid.

    Has anyone ever come up with some clever algorithm whereby you can set the .Top and .Left properties of the form appearing over the grid in the right place, i.e. over the active cell ?

    I'm playing arund at the moment but one minute it works and then on a different cell it works not so well, so I htought I would ask on here.

  2. #2
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: Find Co-Ordinates of selected cell in a grid

    Have you tried using the GetCursorPos API? that would get the cursor on location on the screen and the not form, then u should be able to put the form in the right spot
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  3. #3

    Thread Starter
    Frenzied Member TheBionicOrange's Avatar
    Join Date
    Apr 2001
    Location
    Cardiff, UK
    Posts
    1,818

    Re: Find Co-Ordinates of selected cell in a grid

    No I haven't ... but I will now. Ta.

  4. #4
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Find Co-Ordinates of selected cell in a grid

    Is this for a FlexGrid?

    If so, here's how to get the Top of the active cell (you can guess the Left!):
    VB Code:
    1. MsgBox Me.Top + FlexGrid.Top + FlexGrid.CellTop
    (CellTop etc are always in Twips, so you'll need to convert it if your forms scalemode is anything else)

  5. #5

    Thread Starter
    Frenzied Member TheBionicOrange's Avatar
    Join Date
    Apr 2001
    Location
    Cardiff, UK
    Posts
    1,818

    Re: Find Co-Ordinates of selected cell in a grid

    No its not a flexgrid ... its an "IGrid" (from 10Tech), which doesn't appear to have a "CellTop" and "CellLeft" property.

  6. #6
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Find Co-Ordinates of selected cell in a grid

    Ah.. well in that case Static's idea will probably be the best way.

    The only alternative I can think of to get the CellTop is to use a property like .TopRow (if it has one!) the add the .RowHeight's (if avaiable!) until you reach the correct row.

  7. #7
    Fanatic Member
    Join Date
    Mar 2002
    Location
    AUSTRALIA
    Posts
    603

    Re: Find Co-Ordinates of selected cell in a grid

    Do any of your events return x & y co-ords ?
    EG the SGrid has a mouseup event that does return x & y
    VB Code:
    1. Private Sub SGrid_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
    If you can determine these in some manner, you can then add them to the Form's co-ords to get the positioning you desire.
    Rob C

  8. #8

    Thread Starter
    Frenzied Member TheBionicOrange's Avatar
    Join Date
    Apr 2001
    Location
    Cardiff, UK
    Posts
    1,818

    Re: Find Co-Ordinates of selected cell in a grid

    Yes they do. My Mouse UP events has the following ...

    VB Code:
    1. Private Sub iGrid_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal x As Single, ByVal y As Single, ByVal lRow As Long, ByVal lCol As Long, bDoDefault As Boolean)

  9. #9
    Fanatic Member
    Join Date
    Mar 2002
    Location
    AUSTRALIA
    Posts
    603

    Re: Find Co-Ordinates of selected cell in a grid

    With the SGrid I can position over the cell, but not exactly aligning with the borders.
    The SGrid lacks a property .CellLeft and .CellTop which the flexgrid has.
    If it had those properties, I could align exactly.
    Does your grid have a Cell Left and Cell Top property ?
    Rob C

  10. #10

    Thread Starter
    Frenzied Member TheBionicOrange's Avatar
    Join Date
    Apr 2001
    Location
    Cardiff, UK
    Posts
    1,818

    Re: Find Co-Ordinates of selected cell in a grid

    No it doesn't (see above).

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