|
-
Jul 28th, 2006, 06:12 AM
#1
Thread Starter
Frenzied Member
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.
-
Jul 28th, 2006, 07:07 AM
#2
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"
-
Jul 28th, 2006, 07:09 AM
#3
Thread Starter
Frenzied Member
Re: Find Co-Ordinates of selected cell in a grid
No I haven't ... but I will now. Ta.
-
Jul 28th, 2006, 08:43 AM
#4
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:
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)
-
Jul 28th, 2006, 08:51 AM
#5
Thread Starter
Frenzied Member
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.
-
Jul 28th, 2006, 09:40 AM
#6
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.
-
Jul 28th, 2006, 10:56 AM
#7
Fanatic Member
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:
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.
-
Jul 31st, 2006, 02:38 AM
#8
Thread Starter
Frenzied Member
Re: Find Co-Ordinates of selected cell in a grid
Yes they do. My Mouse UP events has the following ...
VB Code:
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)
-
Jul 31st, 2006, 06:04 AM
#9
Fanatic Member
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 ?
-
Jul 31st, 2006, 06:06 AM
#10
Thread Starter
Frenzied Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|