Imagen en la ultima columna GRID

HMG en Español

Moderator: Rathinagiri

Post Reply
User avatar
AidTIC
Posts: 117
Joined: Mon Apr 22, 2013 8:29 am
DBs Used: DBF
Contact:

Imagen en la ultima columna GRID

Post 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 2359 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
Skydone Solutions
www.skydone.com
edk
Posts: 911
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland

Re: Imagen en la ultima columna GRID

Post 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
User avatar
AidTIC
Posts: 117
Joined: Mon Apr 22, 2013 8:29 am
DBs Used: DBF
Contact:

Re: Imagen en la ultima columna GRID

Post 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
Attachments
2019-02-21_16-51-59.jpg
2019-02-21_16-51-59.jpg (45.95 KiB) Viewed 2333 times
Skydone Solutions
www.skydone.com
edk
Posts: 911
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland

Re: Imagen en la ultima columna GRID

Post 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 2298 times
User avatar
AidTIC
Posts: 117
Joined: Mon Apr 22, 2013 8:29 am
DBs Used: DBF
Contact:

Re: Imagen en la ultima columna GRID

Post 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
Attachments
2019-02-22_19-31-00.jpg
2019-02-22_19-31-00.jpg (49.42 KiB) Viewed 2242 times
Skydone Solutions
www.skydone.com
User avatar
gfilatov
Posts: 1067
Joined: Fri Aug 01, 2008 5:42 am
Location: Ukraine
Contact:

Re: Imagen en la ultima columna GRID

Post 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 2229 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:
Kind Regards,
Grigory Filatov

"Everything should be made as simple as possible, but no simpler." Albert Einstein
edk
Posts: 911
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland

Re: Imagen en la ultima columna GRID

Post 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.
User avatar
SALINETAS24
Posts: 667
Joined: Tue Feb 27, 2018 3:06 am
DBs Used: DBF
Contact:

Re: Imagen en la ultima columna GRID

Post by SALINETAS24 »

Hola, hay un ejemplo en la libreria que igual te puede servir.
Espero que te sirva.
Sl2
Attachments
Grid_ImageIndex.rar
(1.22 MiB) Downloaded 153 times
Como dijo el gran pensador Hommer Simpson..., - En este mundo solo hay 3 tipos de personas, los que saben contar y los que no. :shock:
Post Reply