copy items from a loaded grid to another grid or virtual grid
Moderator: Rathinagiri
copy items from a loaded grid to another grid or virtual grid
hello, I need to copy the items from a grid already loaded to another empty grid or virtual grid, ms I didn't want to use additem with for and next
someone already used something would have some example
someone already used something would have some example
Re: copy items from a loaded grid to another grid or virtual grid
Quizá esto...
\HMG\3.4.4\SAMPLES\Controls\Grid\GRID_01\demo.prg
Los 2 Grid´s utilizan el mismo array.
*----------------------------------------------------------------------
Maybe this ...
\HMG\3.4.4\SAMPLES\Controls\Grid\GRID_01\demo.prg
The 2 Grid's use the same array.
\HMG\3.4.4\SAMPLES\Controls\Grid\GRID_01\demo.prg
Los 2 Grid´s utilizan el mismo array.
*----------------------------------------------------------------------
Maybe this ...
\HMG\3.4.4\SAMPLES\Controls\Grid\GRID_01\demo.prg
The 2 Grid's use the same array.
Andrés González López
Desde Guadalajara, Jalisco. México.
Desde Guadalajara, Jalisco. México.
- serge_girard
- Posts: 3312
- Joined: Sun Nov 25, 2012 2:44 pm
- DBs Used: 1 MySQL - MariaDB
2 DBF - Location: Belgium
- Contact:
Re: copy items from a loaded grid to another grid or virtual grid
Jair,
This maybe?
This maybe?
Code: Select all
FOR xx := 1 to Form_1.Grid_1.Itemcount
aItem := Form_1.Grid_1.Item ( XX )
cITEM1 := STRVALUE(aItem [1] )
cITEM2 := STRVALUE(aItem [2] )
cITEM3 := STRVALUE(aItem [3] )
cITEM9 := STRVALUE(aItem [9] )
cITEM11 := STRVALUE(aItem [11] )
ADD ITEM { cITEM1 , cITEM1 , cITEM3, cITEM9, cITEM11 } TO Grid_2 OF Form_1
NEXT
There's nothing you can do that can't be done...
Re: copy items from a loaded grid to another grid or virtual grid
serge_girard wrote: ↑Tue Nov 10, 2020 8:16 pm Jair,
This maybe?
Code: Select all
FOR xx := 1 to Form_1.Grid_1.Itemcount aItem := Form_1.Grid_1.Item ( XX ) cITEM1 := STRVALUE(aItem [1] ) cITEM2 := STRVALUE(aItem [2] ) cITEM3 := STRVALUE(aItem [3] ) cITEM9 := STRVALUE(aItem [9] ) cITEM11 := STRVALUE(aItem [11] ) ADD ITEM { cITEM1 , cITEM1 , cITEM3, cITEM9, cITEM11 } TO Grid_2 OF Form_1 NEXT
hello Serge, that's exactly what I don't want to do, I would like to take the array already loaded with additem in grid1 and put it at once in grid 2
follow as you like
aGrid1 := Form_Novo_Pedido.Grid_1.item
Form_Novo_Pedido.Grid_2.additem( aGrid1 )
Re: copy items from a loaded grid to another grid or virtual grid
Maybe this will be useful:
(simplified version without error handling)
Example of new functions: HMG_GetGridAllItems (cForm, cGrid) and HMG_GetGridRowItems (cForm, cGrid, nRow)
(version with error handling)
(simplified version without error handling)
Code: Select all
FOR nRow := 1 TO Form_Novo_Pedido.Grid_1.ItemCount
Form_Novo_Pedido.Grid_2.AddItem( _GetItem ( 'Grid_1', 'Form_Novo_Pedido' , nRow ) )
NEXT nRow
(version with error handling)
Code: Select all
#include "hmg.ch"
Function Main
Local aRows [20] [3]
DEFINE WINDOW Form_1 ;
AT 0,0 ;
WIDTH 800 ;
HEIGHT 550 ;
TITLE 'Hello World!' ;
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 TOOLBAR ToolBar_1 BUTTONSIZE 200,20
BUTTON B_CLONE CAPTION " Clone to Grid 2 " ACTION CloneGrid()
BUTTON B_ITEMS CAPTION " List of all items of Grid 2 " ACTION MsgDebug ( HMG_GetGridAllItems ( 'Form_1', 'Grid_2' ) )
BUTTON B_CLEAN CAPTION " Clean Grid 2 " ACTION Form_1.Grid_2.DeleteAllItems
END TOOLBAR
@ 50,10 GRID Grid_1 ;
WIDTH 760 ;
HEIGHT 180 ;
HEADERS {'Last Name','First Name','Phone'} ;
WIDTHS {140,140,140};
ITEMS aRows ;
VALUE {1,1} ;
EDIT ;
JUSTIFY { GRID_JTFY_CENTER,GRID_JTFY_RIGHT, GRID_JTFY_RIGHT } ;
CELLNAVIGATION
@ 240,10 GRID Grid_2 ;
WIDTH 760 ;
HEIGHT 180 ;
HEADERS {'Last Name','First Name','Phone'} ;
WIDTHS {140,140,140};
ITEMS {} ;
VALUE 1
END WINDOW
CENTER WINDOW Form_1
ACTIVATE WINDOW Form_1
Return
***********************************
Function CloneGrid()
Local i
Form_1.Grid_2.DeleteAllItems
FOR i = 1 TO Form_1.Grid_1.ItemCount
Form_1.Grid_2.AddItem ( HMG_GetGridRowItems ( 'Form_1', 'Grid_1', i ) )
NEXT i
RETURN
****************************************************************
Function HMG_GetGridAllItems ( cForm, cGrid )
Local aAllItems := {}, nRow
CHECK TYPE cForm AS CHARACTER, ;
cGrid AS CHARACTER
IF _IsControlDefined ( cGrid , cForm )
cType := GetControlType ( cGrid, cForm)
IF cType == "GRID" .OR. cType == "MULTIGRID"
FOR nRow = 1 TO GetProperty ( cForm, cGrid, 'ItemCount' )
AADD (aAllItems, _GetItem ( cGrid, cForm , nRow ) )
NEXT nRow
ENDIF
ENDIF
RETURN aAllItems
****************************************************************
Function HMG_GetGridRowItems ( cForm, cGrid, nRow )
Local aRowItems := {}, cType
Default nRow := 1
CHECK TYPE cForm AS CHARACTER, ;
cGrid AS CHARACTER, ;
nRow AS NUMERIC
IF _IsControlDefined ( cGrid , cForm )
cType := GetControlType ( cGrid, cForm)
IF ( cType == "GRID" .OR. cType == "MULTIGRID" ) .AND. nRow > 0 .AND. nRow <= GetProperty ( cForm, cGrid, 'ItemCount' )
aRowItems := _GetItem ( cGrid, cForm , nRow )
ENDIF
ENDIF
RETURN aRowItems
Re: copy items from a loaded grid to another grid or virtual grid
EDK, thank you what you were looking for how to doedk wrote: ↑Tue Nov 10, 2020 10:41 pm Maybe this will be useful:
(simplified version without error handling)Example of new functions: HMG_GetGridAllItems (cForm, cGrid) and HMG_GetGridRowItems (cForm, cGrid, nRow)Code: Select all
FOR nRow := 1 TO Form_Novo_Pedido.Grid_1.ItemCount Form_Novo_Pedido.Grid_2.AddItem( _GetItem ( 'Grid_1', 'Form_Novo_Pedido' , nRow ) ) NEXT nRow
(version with error handling)Code: Select all
#include "hmg.ch" Function Main Local aRows [20] [3] DEFINE WINDOW Form_1 ; AT 0,0 ; WIDTH 800 ; HEIGHT 550 ; TITLE 'Hello World!' ; 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 TOOLBAR ToolBar_1 BUTTONSIZE 200,20 BUTTON B_CLONE CAPTION " Clone to Grid 2 " ACTION CloneGrid() BUTTON B_ITEMS CAPTION " List of all items of Grid 2 " ACTION MsgDebug ( HMG_GetGridAllItems ( 'Form_1', 'Grid_2' ) ) BUTTON B_CLEAN CAPTION " Clean Grid 2 " ACTION Form_1.Grid_2.DeleteAllItems END TOOLBAR @ 50,10 GRID Grid_1 ; WIDTH 760 ; HEIGHT 180 ; HEADERS {'Last Name','First Name','Phone'} ; WIDTHS {140,140,140}; ITEMS aRows ; VALUE {1,1} ; EDIT ; JUSTIFY { GRID_JTFY_CENTER,GRID_JTFY_RIGHT, GRID_JTFY_RIGHT } ; CELLNAVIGATION @ 240,10 GRID Grid_2 ; WIDTH 760 ; HEIGHT 180 ; HEADERS {'Last Name','First Name','Phone'} ; WIDTHS {140,140,140}; ITEMS {} ; VALUE 1 END WINDOW CENTER WINDOW Form_1 ACTIVATE WINDOW Form_1 Return *********************************** Function CloneGrid() Local i Form_1.Grid_2.DeleteAllItems FOR i = 1 TO Form_1.Grid_1.ItemCount Form_1.Grid_2.AddItem ( HMG_GetGridRowItems ( 'Form_1', 'Grid_1', i ) ) NEXT i RETURN **************************************************************** Function HMG_GetGridAllItems ( cForm, cGrid ) Local aAllItems := {}, nRow CHECK TYPE cForm AS CHARACTER, ; cGrid AS CHARACTER IF _IsControlDefined ( cGrid , cForm ) cType := GetControlType ( cGrid, cForm) IF cType == "GRID" .OR. cType == "MULTIGRID" FOR nRow = 1 TO GetProperty ( cForm, cGrid, 'ItemCount' ) AADD (aAllItems, _GetItem ( cGrid, cForm , nRow ) ) NEXT nRow ENDIF ENDIF RETURN aAllItems **************************************************************** Function HMG_GetGridRowItems ( cForm, cGrid, nRow ) Local aRowItems := {}, cType Default nRow := 1 CHECK TYPE cForm AS CHARACTER, ; cGrid AS CHARACTER, ; nRow AS NUMERIC IF _IsControlDefined ( cGrid , cForm ) cType := GetControlType ( cGrid, cForm) IF ( cType == "GRID" .OR. cType == "MULTIGRID" ) .AND. nRow > 0 .AND. nRow <= GetProperty ( cForm, cGrid, 'ItemCount' ) aRowItems := _GetItem ( cGrid, cForm , nRow ) ENDIF ENDIF RETURN aRowItems
- AUGE_OHR
- Posts: 2095
- Joined: Sun Aug 25, 2019 3:12 pm
- DBs Used: DBF, PostgreSQL, MySQL, SQLite
- Location: Hamburg, Germany
Re: copy items from a loaded grid to another grid or virtual grid
hi,
how to DragDrop from GRID_1 to GRID_2
i have OnCLick which include "mouse click down and up"
what i need is "mouse click down" WM_LBUTTONDOWN and "mouse click up" WM_LBUTTONUP for Start / Stop DragDrop.
how to DragDrop from GRID_1 to GRID_2

i have OnCLick which include "mouse click down and up"
what i need is "mouse click down" WM_LBUTTONDOWN and "mouse click up" WM_LBUTTONUP for Start / Stop DragDrop.
have fun
Jimmy
Jimmy
Re: copy items from a loaded grid to another grid or virtual grid
My solution for grids, edit boxes, rich edit boxes, texts, lists:
http://hmgforum.com/viewtopic.php?p=53811#p53811
and also for trees:
http://hmgforum.com/viewtopic.php?p=57440#p57440
Here is the latest version: Added two functions:
HMG_DaD_DragControlEnable( cDragFromForm, cDragFromControl, lEnabled )
HMG_DaD_DropControlEnable( cDropToForm, cDropToControl, lEnabled)
Re: copy items from a loaded grid to another grid or virtual grid
+1
Who will update on Github
BPD
Convert Dream into Reality through HMG
Convert Dream into Reality through HMG
Re: copy items from a loaded grid to another grid or virtual grid
hello because the load window with variable passed by parameter doesn't work
Code: Select all
***********************************
Function CloneGrid(oForm_1,oGrid_1,oForm_2,oGrid_2)
Local i
PRIVATE oForm1 := oForm_1 //
PRIVATE oGrid1 := oGrid_1 //
PRIVATE oForm2 := oForm_2 //
PRIVATE oGrid2 := oGrid_2 //
DECLARE WINDOW &oForm1.
DECLARE WINDOW &oForm2.
DECLARE &oGrid1.
DECLARE &oGrid2.
Load Window oForm_2
//&oForm_1.vartostr(&oGrid_1).DeleteAllItems
FOR i = 1 TO &oForm1..&oGrid1..ItemCount
&oForm2..&oGrid2..AddItem ( HMG_GetGridRowItems ( oForm_1, oGrid_1, i ) )
NEXT i
&oForm2..Center
&oForm2..Activate
RETURN