Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Center a Row in Grid
Message
De
10/06/2002 12:27:50
 
 
À
10/06/2002 00:55:08
Lutz Scheffler
Lutz Scheffler Software Ingenieurbüro
Dresden, Allemagne
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00663970
Message ID:
00666587
Vues:
24
Have you tried doing this using the grid's relative row property? For Example:

LOCAL lnRows, lnLoop

THISFORM.LOCKSCREEN = .T.
WITH oGrid
lnRows = ROUND(((.HEIGHT-.HEADERHEIGHT)/.ROWHEIGHT)/2,0)
.SetFocus()
DO WHILE (.RelativeRow < lnRows) OR ;
( .ActiveRow < lnRows AND .ActiveRow = .RelativeRow)
.DOSCROLL(0) && Scroll Up
ENDDO
ENDWITH
THISFORM.LOCKSCREEN = .F.

Mace

>Hi Macer,
>thank you for the idea. I was thinking about it. But the grid is a class and know nothing about the parent it is used in. So I have no information about a target of setfocus or even if there is a target to set the focus to.
>
>Agnes
>
>>Agnes,
>>
>>Can't you just move the focus before the code is run using setfocus.
>>
>>Mace
>>
>>>Hi All,
>>>I have a problem centering the active row in the visible part of a grid.
>>>
>>>I use a code similar to
>>>
>>>LOCAL;
>>> lnHeight AS INTEGER,;
>>> lnRows   AS INTEGER,;
>>> lnLoop   AS INTEGER
>>>
>>>
>>>WITH oGrid
>>> lnHeight = .HEIGHT
>>> lnRows   = ROUND(((lnHeight-.HEADERHEIGHT)/.ROWHEIGHT)/2,0)
>>> .HEIGHT = .ROWHEIGHT+.HEADERHEIGHT
>>>
>>> .REFRESH()
>>> .HEIGHT = lnHeight
>>> FOR lnLoop = 1 TO lnRows-1
>>>  .DOSCROLL(0)
>>> ENDFOR &&lnLoop
>>>ENDWITH &&oGrid
>>>
>>>
>>>this works fine as long as the grid is not in focus. If the grid is in focus and the code beyond is run, the recordpointer will move. This is not easy to trace, because the grid needs to be in focus. I figured out that the change of recordpointer happens in REFRESH(). There is no code in REFRESH() event, I've checked with a plain grid.
>>>So I put some code in BEFORROWCOLCHANGE to stop moving of RecordPointer if the grid is centering. The movement stops, but then no centering occurs. Same happens if the stop of moving is triggered in textbox VALID()
>>>
>>>So I look for a idea to get the thing centered with the record activated before REFRESH()
>>>
>>>TIA
>>>Agnes
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform