Hi guys!
I have a form with 2 GRIDs. First Grid contains 6 rows headers, seceond - which is much longer can be scrolled.
But, sometimes I have more columns that don't feet to screen. I have to scroll horizontally, to see last columns.
I want to synchronize horizontal scrolling.
Do somebody knows how to do it? How to catch OnScroll situation in GRID control?
Grid and OnScroll event
Moderator: Rathinagiri
- serge_girard
- Posts: 3167
- Joined: Sun Nov 25, 2012 2:44 pm
- DBs Used: 1 MySQL - MariaDB
2 DBF - Location: Belgium
- Contact:
Re: Grid and OnScroll event
Marek,
I know how to synchronize scrollbars vertically but horizontally not yet...
Serge
I know how to synchronize scrollbars vertically but horizontally not yet...
Serge
There's nothing you can do that can't be done...
Re: Grid and OnScroll event
Cześć Marku.
Czy ilość kolumn w obu siatkach jest taka sama?
Czy ilość kolumn w obu siatkach jest taka sama?
Re: Grid and OnScroll event
Tak, Exactly
Re: Grid and OnScroll event
Hi Marek.
I cannot catch Windows Message WM_HSCROLL to fully synchronize the sliders (WM_HSCROLL is not passed from the Grid control event).
I do not know if you will be satisfied with my solution - it is based on the "synchronization" of the focus of the columns of both grids.
This has downsides, including that both grids need to be navigated across cells, not rows.
I cannot catch Windows Message WM_HSCROLL to fully synchronize the sliders (WM_HSCROLL is not passed from the Grid control event).
I do not know if you will be satisfied with my solution - it is based on the "synchronization" of the focus of the columns of both grids.
This has downsides, including that both grids need to be navigated across cells, not rows.
Code: Select all
#include "hmg.ch"
Function Main
Local aRows [20] [3]
DEFINE WINDOW Form_1 ;
AT 0,0 ;
WIDTH 800 ;
HEIGHT 520 ;
TITLE 'Cell Navigation Grid Test' ;
MAIN
aRows [1] := {'Simpson','Homer','555-5555'}
aRows [2] := {'Mulder','Fox','324-6432'}
aRows [3] := {'Smart','Max','432-5892'}
aRows [4] := {'Grillo','Pepe','894-2332'}
aRows [5] := {'Kirk','James','346-9873'}
aRows [6] := {'Barriga','Carlos','394-9654'}
aRows [7] := {'Flanders','Ned','435-3211'}
aRows [8] := {'Smith','John','123-1234'}
aRows [9] := {'Pedemonti','Flavio','000-0000'}
aRows [10] := {'Gomez','Juan','583-4832'}
aRows [11] := {'Fernandez','Raul','321-4332'}
aRows [12] := {'Borges','Javier','326-9430'}
aRows [13] := {'Alvarez','Alberto','543-7898'}
aRows [14] := {'Gonzalez','Ambo','437-8473'}
aRows [15] := {'Batistuta','Gol','485-2843'}
aRows [16] := {'Vinazzi','Amigo','394-5983'}
aRows [17] := {'Pedemonti','Flavio','534-7984'}
aRows [18] := {'Samarbide','Armando','854-7873'}
aRows [19] := {'Pradon','Alejandra','???-????'}
aRows [20] := {'Reyes','Monica','432-5836'}
DEFINE GRID Grid_1
ROW 10
COL 10
WIDTH 380
HEIGHT 470
HEADERS {'Last Name','First Name','Phone'}
WIDTHS {140,140,140}
ITEMS aRows
VALUE { 1 , 1 }
TOOLTIP 'Editable Grid Control'
ALLOWEDIT .T.
CELLNAVIGATION .T.
JUSTIFY { GRID_JTFY_LEFT,GRID_JTFY_RIGHT, GRID_JTFY_RIGHT }
ONCLICK Sync_Cols('Grid_1','Grid_2')
ONKEY Sync_Cols('Grid_1','Grid_2')
END GRID
DEFINE GRID Grid_2
ROW 10
COL 400
WIDTH 380
HEIGHT 470
HEADERS {'Last Name','First Name','Phone'}
WIDTHS {140,140,140}
ITEMS aRows
VALUE { 1 , 1 }
ON HEADCLICK { {||MsgInfo('Click 1')} , {||MsgInfo('Click 2')} , {||MsgInfo('Click 3')} }
JUSTIFY { GRID_JTFY_LEFT,GRID_JTFY_CENTER, GRID_JTFY_CENTER }
CELLNAVIGATION .T.
ONCLICK Sync_Cols('Grid_2','Grid_1')
ONKEY Sync_Cols('Grid_2','Grid_1')
END GRID
END WINDOW
CENTER WINDOW Form_1
ACTIVATE WINDOW Form_1
Return
**********************************************************************************************
Function Sync_Cols( cSource, cDest )
Local nSourceCol := GetProperty ( 'Form_1', cSource, 'Value' ) [ 2 ]
Local nDestCol := GetProperty ( 'Form_1', cDest, 'Value' ) [ 2 ]
IF HMG_GetLastMouseMessage() = WM_LBUTTONDOWN .AND. nSourceCol <> GetProperty ( 'Form_1', cSource, 'CellColClicked' )
//The cell you clicked has no focus yet.
SetProperty ( 'Form_1', cDest , 'Value', { GetProperty ( 'Form_1', cDest , 'Value' ) [ 1 ], GetProperty ( 'Form_1', cSource, 'CellColClicked' ) } )
SetProperty ( 'Form_1', cSource, 'Value', { GetProperty ( 'Form_1', cSource, 'Value' ) [ 1 ], GetProperty ( 'Form_1', cSource, 'CellColClicked' ) } )
DO Events
ENDIF
DO WHILE nDestCol <> nSourceCol
DoMethod ( 'Form_1', cDest, 'SetFocus' )
IF nDestCol < nSourceCol
HMG_PressKey ( VK_RIGHT )
ELSE
HMG_PressKey ( VK_LEFT )
ENDIF
DO Events
DoMethod ( 'Form_1', cSource, 'SetFocus' )
nSourceCol := GetProperty ( 'Form_1', cSource, 'Value' ) [ 2 ]
nDestCol := GetProperty ( 'Form_1', cDest, 'Value' ) [ 2 ]
ENDDO
RETURN Nil
Re: Grid and OnScroll event
Thank you Edward, but I need row navigation in this case