Page 1 of 1

Imagen en la ultima columna GRID

Posted: Thu Feb 21, 2019 12:03 pm
by AidTIC
Hola,

Como puedo hacer que en la ultima columna de mi grid aparezca una imagen y que no salga en la primera columna.

Gracias


Hello,

How can I make an image appear in the last column of my grid and not appear in the first column?

Thank you

2019-02-21_12-53-58.jpg
2019-02-21_12-53-58.jpg (42.08 KiB) Viewed 2646 times

Code: Select all

#include "hmg.ch"


Function Main

   aItems := {}

   AADD (aItems, {"Carrot",        5 , 0 } )
   AADD (aItems, {"Cauliflower",   0 , 0 })
   AADD (aItems, {"Corn",         15 , 0 })
   AADD (aItems, {"Tomato",        0 , 0 })
   AADD (aItems, {"Zucchini",     20 , 0 })


   DEFINE WINDOW Form_1 ;
      AT 0,0 ;
      WIDTH 600 ;
      HEIGHT 400 ;
      MAIN 

      @ 10,10 GRID Grid_1 ;
         WIDTH 550 ;
         HEIGHT 330 ;
         HEADERS {'Product','Stock',"DEL"} ;
         WIDTHS {250,150,40};
         ITEMS aItems;
         ON CHANGE Test_Value();
         EDIT;
         CELLNAVIGATION;
 
   END WINDOW

   Form_1.Grid_1.ColumnJUSTIFY (2) := GRID_JTFY_RIGHT
 
   Form_1.Grid_1.Image (.T.) := {"_No.bmp" }
  
   FOR i = 1 TO Form_1.Grid_1.ItemCount
    
       Form_1.Grid_1.ImageIndex (i,3) := 0  // _No.bmp
  
   NEXT


   CENTER WINDOW Form_1

   ACTIVATE WINDOW Form_1

Return


Procedure Test_Value
 
Return

Re: Imagen en la ultima columna GRID

Posted: Thu Feb 21, 2019 1:15 pm
by edk
Try:

Code: Select all

FOR i = 1 TO Form_1.Grid_1.ItemCount
       Form_1.Grid_1.ImageIndex (i,1) := Nil
       Form_1.Grid_1.ImageIndex (i,3) := 0  // _No.bmp
NEXT

Re: Imagen en la ultima columna GRID

Posted: Thu Feb 21, 2019 3:55 pm
by AidTIC
Perdona, la tabla la genero ADD ITEM, y no le hago ir.

Sorry, the table is created by ADD ITEM, and I do not make it go.

Image

Code: Select all

#include "hmg.ch"


Function Main

   aItems := {}

   DEFINE WINDOW Form_1 ;
      AT 0,0 ;
      WIDTH 600 ;
      HEIGHT 400 ;
      MAIN ;
	  on init Test_Value()

      @ 10,10 GRID Grid_1 ;
         WIDTH 550 ;
         HEIGHT 330 ;
         HEADERS {'Product','Stock',"DEL"} ;
         WIDTHS {250,150,40};
         ON CHANGE Test_Value();
         EDIT;
         CELLNAVIGATION;
 
   END WINDOW

   Form_1.Grid_1.ColumnJUSTIFY (2) := GRID_JTFY_RIGHT
 
   Form_1.Grid_1.Image (.T.) := {"_No.bmp" }
  
   FOR i = 1 TO Form_1.Grid_1.ItemCount
       Form_1.Grid_1.ImageIndex (i,1) := Nil
       Form_1.Grid_1.ImageIndex (i,3) := 0  // _No.bmp
  
   NEXT


   CENTER WINDOW Form_1

   ACTIVATE WINDOW Form_1

Return


Procedure Test_Value
       For x := 1 to 100
	      ADD ITEM {  STRZERO( X , 2 ), STRZERO( x * 100 , 3 ) , 0 } TO Grid_1 OF Form_1
	   Next x	  
Return

Re: Imagen en la ultima columna GRID

Posted: Thu Feb 21, 2019 8:40 pm
by edk

Code: Select all

#include "hmg.ch"


Function Main

   aItems := {}

   DEFINE WINDOW Form_1 ;
      AT 0,0 ;
      WIDTH 600 ;
      HEIGHT 400 ;
      MAIN ;
	  on init Test_Value()

      @ 10,10 GRID Grid_1 ;
         WIDTH 550 ;
         HEIGHT 330 ;
         HEADERS {'Product','Stock',"DEL"} ;
         WIDTHS {250,150,40};
         ON CHANGE Test_Value();
         EDIT;
         CELLNAVIGATION;
 
   END WINDOW

   Form_1.Grid_1.ColumnJUSTIFY (2) := GRID_JTFY_RIGHT
 
   Form_1.Grid_1.Image (.T.) := {"_No.bmp" }
  


   CENTER WINDOW Form_1

   ACTIVATE WINDOW Form_1

Return


Procedure Test_Value
       For x := 1 to 100
	      ADD ITEM {  STRZERO( X , 2 ), STRZERO( x * 100 , 3 ) , 0 } TO Grid_1 OF Form_1
       		Form_1.Grid_1.ImageIndex ( Form_1.Grid_1.ItemCount , 1 ) := Nil
       		Form_1.Grid_1.ImageIndex ( Form_1.Grid_1.ItemCount , 3 ) := 0  // _No.bmp
  	   Next x	  
Return
Bez tytułu.png
Bez tytułu.png (12.22 KiB) Viewed 2585 times

Re: Imagen en la ultima columna GRID

Posted: Fri Feb 22, 2019 6:33 pm
by AidTIC
El espacio que queda en la primera columna, se puede eliminar?

Gracias

Can the space left in the first column be removed?
Thank you


Image

Re: Imagen en la ultima columna GRID

Posted: Fri Feb 22, 2019 8:33 pm
by gfilatov
AidTIC wrote: Fri Feb 22, 2019 6:33 pm El espacio que queda en la primera columna, se puede eliminar?

Gracias

Can the space left in the first column be removed?
Thank you
Hi,

I think that it is impossible with the current Grid's imlementation in hmg.

But you can use the powerful TSBrowse library for your need.

Please take a look for an image below
grid-tsb.png
grid-tsb.png (29.84 KiB) Viewed 2516 times
and a sample code is

Code: Select all

// Browsing an array with TSBrowse
#include "hmg.ch"
#include "TSBrowse.ch"

static Grid_1

Function Main

   aItems := {}

   SET FONT TO "Arial", 10

   DEFINE WINDOW Form_1 ;
      AT 0,0 ;
      WIDTH 600 ;
      HEIGHT 400 ;
      MAIN ;
      on init Test_Value()

      @ 10,10 TBROWSE Grid_1 ;
         ARRAY aItems;
         WIDTH 550 ;
         HEIGHT 330 ;
         HEADERS {'Product','Stock',"DEL"} ;
         WIDTHS {250,150,40};
         PICTURE '@K !xxxxxxxxxxxxxxxxx','@K 9999','' ;
         IMAGE "_No.bmp","_No.bmp";
         EDIT;
         CELLED;
         JUSTIFY { DT_CENTER, DT_RIGHT, DT_CENTER}

      WITH OBJECT Grid_1
         :SetAlign( 2, 1, DT_RIGHT )   // ( nCol, nLevel, nAlign )

         :SetColor( { CLR_FOCUSB }, { RGB( 51, 153, 254 ) } )

         :nLineStyle :=  LINES_NONE
         :nHeightCell += 6
         :nHeightHead += 8
      END WITH

   END WINDOW

   CENTER WINDOW Form_1

   ACTIVATE WINDOW Form_1

Return


Procedure Test_Value
local x

   For x := 1 to 100
      ADD ITEM {  STRZERO( X , 2 ), x * 100 , 1 } TO Grid_1 OF Form_1
   Next x

   WITH OBJECT Grid_1
      :aColumns[ 3 ]:lBitMap   := .T.
      :aColumns[ 3 ]:lEdit     := .F.
      :aColumns[ 3 ]:lIndexCol := .F.
   END WITH

Return
Hope that useful :idea:

Re: Imagen en la ultima columna GRID

Posted: Fri Feb 22, 2019 9:40 pm
by edk
gfilatov wrote: Fri Feb 22, 2019 8:33 pm Hi,

I think that it is impossible with the current Grid's imlementation in hmg.
+1
Indeed. According to the Grid sources, the width of the first column is always expanded by the width of the first image + 2 pixels. Interestingly, if you specify an image with a different index, its width will not be larger than the image with index 0.

Re: Imagen en la ultima columna GRID

Posted: Fri Feb 22, 2019 10:05 pm
by SALINETAS24
Hola, hay un ejemplo en la libreria que igual te puede servir.
Espero que te sirva.
Sl2