How to change the start column in an inplace edit grid control (non CellNavigation mode)

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
trmpluym
Posts: 303
Joined: Tue Jul 15, 2014 6:52 pm
Location: The Netherlands

How to change the start column in an inplace edit grid control (non CellNavigation mode)

Post by trmpluym »

For example when i use the GRID demo 20 (c:\hmg.3.4.3\SAMPLES\Controls\Grid\GRID_20) and a start to edit a line this looks like this:
1.png
1.png (4.15 KiB) Viewed 3183 times
When i press enter i automaticly can edit the second column
2.png
2.png (5.63 KiB) Viewed 3183 times
The same for the next columns. When i press ESC the editing is canceled.
3.png
3.png (3.49 KiB) Viewed 3183 times
But when i press enter again on the same line the editing continues with the last edited column.
2.png
2.png (5.63 KiB) Viewed 3183 times
How can i change this behaviour to always startover with the first column
1.png
1.png (4.15 KiB) Viewed 3183 times
Is there maybe a variable or a property i can set to 'column 1' ?

Theo
Last edited by trmpluym on Sun May 29, 2016 6:38 am, edited 1 time in total.
ASESORMIX
Posts: 192
Joined: Thu Oct 25, 2012 8:08 pm
Location: Bqto, Venezuela

Re: How to change the start column in an inplace edit grid control (non CellNavigation mode)

Post by ASESORMIX »

En español:

Yo lo resolvi de esta manera ( no se si es la mas adecuada )

En h_grid.prg modifiqué la linea (1018 aproximadamente ) donde se activa la tecla escape para dejar de leer en la celda:
ON KEY ESCAPE ACTION ( _HMG_SYSDATA [ 256 ] := .T. , THISWINDOW.RELEASE )

y la compuse asi:
ON KEY ESCAPE ACTION ( _HMG_SYSDATA [ 256 ] := .T. ,_HMG_SYSDATA [ 340 ] := 1, THISWINDOW.RELEASE )

Luego apliqué BuildAllLib.bat volvi a generar el ehecutable y funcionó.

Si logras una manera mejor por favor compartela
Espero te ayude.

In English:

I solved it this way ( if not the most suitable )

In h_grid.prg I modified the line ( approximately 1018 ) where the escape key to stop reading in the cell is activated :
KEY ACTION ON ESCAPE ( _HMG_SYSDATA [256 ] : = .T , THISWINDOW.RELEASE . )

and composed as follows:
KEY ACTION ON ESCAPE ( _HMG_SYSDATA [256 ] : = .T , _HMG_SYSDATA [340 ] . = 1 , THISWINDOW.RELEASE )

Then I apply BuildAllLib.bat I returned to generate the ehecutable and it worked.

If you achieve a better way please share it
I hope to help you.
ASESORMIX
Posts: 192
Joined: Thu Oct 25, 2012 8:08 pm
Location: Bqto, Venezuela

Re: How to change the start column in an inplace edit grid control (non CellNavigation mode)

Post by ASESORMIX »

Hola.

Hice nuevas pruebas.

Sin hacer cambios en h_grid.prg.
Ni tampoco usar BuildAllLib.bat

Observa este ejemplo, creo que funciona.

Code: Select all


#include "hmg.ch"

Function Main

Local aRows [20] [3]

PRIVATE cGridName := ""

   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'} 

      @ 10,10 GRID Grid_1 ;
         WIDTH 760 ;
         HEIGHT 240 ;
         HEADERS {'Last Name','First Name','Phone'} ;
         WIDTHS {140,140,140};
         ITEMS aRows ;
         VALUE {1,1} ;
         TOOLTIP 'Editable Grid Control' ;
         EDIT ;
         JUSTIFY { GRID_JTFY_CENTER,GRID_JTFY_RIGHT, GRID_JTFY_RIGHT } ;
         CELLNAVIGATION;
         ON GOTFOCUS cGridName := This.Name


      @ 250,10 GRID Grid_2 ;
         WIDTH 760 ;
         HEIGHT 240 ;
         HEADERS {'Last Name','First Name','Phone'} ;
         WIDTHS {140,140,140};
         ITEMS aRows ;
         VALUE 1 EDIT ;
         TOOLTIP 'Editable Grid Control' ;
         ON HEADCLICK { {||MsgInfo('Click 1')} , {||MsgInfo('Click 2')} , {||MsgInfo('Click 3')} } ;
         JUSTIFY { GRID_JTFY_LEFT,GRID_JTFY_CENTER, GRID_JTFY_CENTER };
         ON GOTFOCUS cGridName := This.Name


   END WINDOW

   CREATE EVENT PROCNAME GridInplace()
   
   CENTER WINDOW Form_1

   ACTIVATE WINDOW Form_1

Return


FUNCTION GridInplace()
   IF _HMG_GridInplaceEdit_ControlHandle <> 0   // Grid Inplace Edit is in course
      IF HMG_GetLastVirtualKeyDown() == VK_F2
         HMG_CleanLastVirtualKeyDown() 
         This.CellValue := "Press Key " + cGridName
         IF HMG_UPPER( cGridName ) == HMG_UPPER( "Grid_1" )
            RETURN 1     // Abort processing the F2 key
         ELSE
            RETURN NIL   // Continue processing the F2 key
         ENDIF
      elseif HMG_GetLastVirtualKeyDown() == VK_ESCAPE
        _HMG_SYSDATA [ 340 ] := 1
      ENDIF
   ENDIF
RETURN NIL


trmpluym
Posts: 303
Joined: Tue Jul 15, 2014 6:52 pm
Location: The Netherlands

Re: How to change the start column in an inplace edit grid control (non CellNavigation mode)

Post by trmpluym »

Asesormix !

Many thanks changing the value _HMG_SYSDATA [ 340 ] to 1 is the solution !!!

I changed my code with the line from your solution:

_HMG_SYSDATA [ 340 ] := 1

And now it works like a charm :D

Many thanks again for helping me out !
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: How to change the start column in an inplace edit grid control (non CellNavigation mode)

Post by Rathinagiri »

Very nice! Thanks for finding the bug. We shall update in the next patch!
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
srvet_claudio
Posts: 2193
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Contact:

Re: How to change the start column in an inplace edit grid control (non CellNavigation mode)

Post by srvet_claudio »

I will update
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com
Post Reply