grid como Excel

HMG en Español

Moderator: Rathinagiri

Post Reply
User avatar
Renegado
Posts: 88
Joined: Tue Mar 11, 2014 11:59 pm

grid como Excel

Post by Renegado »

Hola a todos.
Modifiqué un poco el código del demo39 porque necesitaba salir de la edición del grid con un simple ENTER. Habrá una forma mas simple de hacerlo?
y mi otra duda: si en mi aplicación original hice el grid con el IDE cómo adecuar el On Key? , tambien el On Click en el script, por ejemplo:
Frm_sumativa.grid_2.On Click onclick() <---esto no me funciona

Hi all
I modified the demo39 code because I needed to exit the grid edit with a simple ENTER. Will there be a simpler way to do it?
And my other question: if in my original application I did the grid with the IDE how to adapt the On Key? , Also the On Click in the script, for example:
Frm_sumativa.grid_2.On Click onclick () <---this does not work

Code: Select all

/*
* HMG Data-Bound Grid Demo
* (c) 2010 Roberto Lopez
*/

#include <hmg.ch>

Function Main

   SET CELLNAVIGATIONMODE EXCEL

   define window sample at 0, 0 width 320 height 200 title 'Sample Cell Navigation Downwards...' main
      define grid grid_1
         row 10
         col 10
         width 300
         height 150
         widths { 100, 170 }
         headers { 'Criterios', 'Puntos'}
         ON KEY   onkey()   //como ponerlo si usé el IDE para crear el grid
         cellnavigation .t.
         on click   navega()  //como ponerlo si usé el IDE para crear el grid
         on dblclick navega()
         columnwhen {   {|| This.Cellvalue>='A'}, {|| This.Cellvalue>=0}}
         columncontrols {  { 'TEXTBOX', 'CHARACTER' },{ 'TEXTBOX', 'NUMERIC', '999' } }
         allowedit .t.
         items { { 'Cuaderno', 0 }, { 'Participacion', 0 }, { 'Tarea', 0 }, { 'Examen', 0 } }
      end grid         
   end window
   sample.center
   sample.activate
   Return

   function onkey()
   if this.cellrowindex==4
   if HMG_GetLastVirtualKeyDown()==13
      sample.grid_1.cellnavigation := .f.
      endif
      endif
   return

   function navega()
   sample.grid_1.cellnavigation:= .t.
   return
Gracias.
Atentamente: Antonio
GRID_39.rar
(1.2 MiB) Downloaded 213 times
mlnr
Posts: 127
Joined: Fri Aug 28, 2015 1:52 pm
DBs Used: DBF

Re: grid como Excel

Post by mlnr »

Hi Antonio,

Try this code.

Code: Select all

   function onkey()
   
     if GetProperty("sample","Grid_1","Cellnavigation") = .T. .And. HMG_GetLastVirtualKeyDown () == VK_RETURN 
       SetProperty("sample","Grid_1","Cellnavigation",.F.)
     endif

   return
User avatar
Renegado
Posts: 88
Joined: Tue Mar 11, 2014 11:59 pm

Re: grid como Excel

Post by Renegado »

Thanks Gabor, they are 4 rows and in the last one must leave edition but if the user wants to return to modify, I added:

Code: Select all

 function onkey()
      If this.cellrowindex= 4 .And. GetProperty("sample","Grid_1","Cellnavigation") = .T. .And. HMG_GetLastVirtualKeyDown () == VK_RETURN 
       SetProperty("sample","Grid_1","Cellnavigation",.F.)
       Else
       SetProperty("sample","Grid_1","Cellnavigation",.T.)
     Endif
   return
registro.png
registro.png (58.65 KiB) Viewed 2067 times
But now I do not know what the syntax of the "On Key" is if the grid I did with the IDE
Post Reply