Cambiar imágenes en Grid

HMG en Español

Moderator: Rathinagiri

Post Reply
arroya2
Posts: 172
Joined: Thu Aug 06, 2009 7:16 am

Cambiar imágenes en Grid

Post by arroya2 »

Hola amigos.

Las imágines de este GRID dependen de si lSelec es verdadero o falso.
Lo que necesito es que, si el valor de lSelec cambia, lo haga tambien su imagen correspondiente.

Code: Select all

	@ 10, 10 GRID Grid_1 OF wTablaAviso ;
		WIDTH 800 ;
		HEIGHT 301 ;
		HEADERS { '', 'Nombre y Apellidos' } ;
		WIDTHS { 0, 760 } ;
		ROWSOURCE 'Clientes' ;
		COLUMNFIELDS { 'Clientes->lSelec', 'Rtrim(Clientes->Nombre)+" "+Rtrim(Clientes->Apellidos)' } ;
		FONT 'Arial' ;
		SIZE 14 ;
		IMAGE {'Led_On', 'Nada'}
¿Cómo lo puedo hacer?

Gracias
Rafael Pérez
Translated by Google:

Hello friends.

The images from this GRID lSelec depend on whether true or false.
What I need is that if the value of lSelec changes, it does also its corresponding image.

Code: Select all

	@ 10, 10 GRID Grid_1 OF wTablaAviso ;
		WIDTH 800 ;
		HEIGHT 301 ;
		HEADERS { '', 'Nombre y Apellidos' } ;
		WIDTHS { 0, 760 } ;
		ROWSOURCE 'Clientes' ;
		COLUMNFIELDS { 'Clientes->lSelec', 'Rtrim(Clientes->Nombre)+" "+Rtrim(Clientes->Apellidos)' } ;
		FONT 'Arial' ;
		SIZE 14 ;
		IMAGE {'Led_On', 'Nada'}
How I can do?

Thanks
Rafael Perez
User avatar
IMATECH
Posts: 188
Joined: Sun May 27, 2012 9:33 pm
Location: Brazil: Goiânia-GO.

Re: Cambiar imágenes en Grid

Post by IMATECH »

Hi !

To work as espected,
All array image names need a valid image resource...

file.rc

Code: Select all


Led_On   BITMAP ..\Res\Led_On.bmp
Nada     BITMAP ..\Res\Blank_image.bmp

Last edited by IMATECH on Sun Jul 15, 2012 9:15 pm, edited 1 time in total.
M., Ronaldo

By: IMATECH

Imation Tecnologia
arroya2
Posts: 172
Joined: Thu Aug 06, 2009 7:16 am

Re: Cambiar imágenes en Grid

Post by arroya2 »

Hola M., Ronaldo eso lo tengo bien, te muestro el código:

Code: Select all

// Using a resource file like this, you can include bitmaps, icons and sounds
// inside EXE.
//
// Resource   Resource  Resource 
// name       Type      FileName
//
	Led_On     BITMAP	\Iconos\Led_On.bmp
	Nada	      BITMAP	\Iconos\Nada.bmp
	Add  	        ICON		\Iconos\Add.ico
	First    	ICON		\Iconos\First.ico
	Last    	ICON		\Iconos\Last.ico
	Left    	ICON		\Iconos\Left.ico
	Right    	ICON		\Iconos\Right.ico
	F01     	ICON		\Iconos\F01.ico
	F02     	ICON		\Iconos\F02.ico
	F03     	ICON		\Iconos\F03.ico
	F04     	ICON		\Iconos\F04.ico
	F05     	ICON		\Iconos\F05.ico
	F06     	ICON		\Iconos\F06.ico
	F07     	ICON		\Iconos\F07.ico
	F08     	ICON		\Iconos\F08.ico
	F09     	ICON		\Iconos\F09.ico
	F10     	ICON		\Iconos\F10.ico
	F11     	ICON		\Iconos\F11.ico
	F12     	ICON		\Iconos\F12.ico
Al ejecutar el programa, cuando se crea el GRID las imágenes se cargan correctamente para cada registro según el valor de lSelec. Posteriormente si se cambia el valor de lSelec, las imágenes que se cargaron al principio no cambian. Si lSelec:=.F. la imagen debe ser 'Led-On', si lSelec:=.T. la imagen debe ser 'Nada'
Resumiendo las imágenes se cargan correctamente en la creación del GRID, pero si cambio el valor de lSelec en cualquier registro, la imagen permanece sin cambiar.

Me imagino que se debe incluir en las propiedades del GRID alguna función o procedimiento en 'ON CHANGE', ¿pero cómo?

Saludos
Rafael Pérez
Translated by Google:

Hi M., Ronaldo. I have it so good, I show the code:

Code: Select all

	Led_On     BITMAP	\Iconos\Led_On.bmp
	Nada	      BITMAP	\Iconos\Nada.bmp
	Add  	        ICON		\Iconos\Add.ico
	First    	ICON		\Iconos\First.ico
	Last    	ICON		\Iconos\Last.ico
	Left    	ICON		\Iconos\Left.ico
	Right    	ICON		\Iconos\Right.ico
	F01     	ICON		\Iconos\F01.ico
	F02     	ICON		\Iconos\F02.ico
	F03     	ICON		\Iconos\F03.ico
	F04     	ICON		\Iconos\F04.ico
	F05     	ICON		\Iconos\F05.ico
	F06     	ICON		\Iconos\F06.ico
	F07     	ICON		\Iconos\F07.ico
	F08     	ICON		\Iconos\F08.ico
	F09     	ICON		\Iconos\F09.ico
	F10     	ICON		\Iconos\F10.ico
	F11     	ICON		\Iconos\F11.ico
	F12     	ICON		\Iconos\F12.ico
When you run the program, when you create the images load GRID correctly for each record based on the value of lSelec. Then if you change the value of lSelec, images that were loaded at first change. If lSelec: =. F. the image must be 'Led-On', if lSelec: =. T. the image must be 'Nada'
In short: the images are loaded correctly in the creation of GRID, but if I change the value of lSelec in any record, the image remains unchanged.

I imagine that must be included in the properties of a function or procedure GRID 'ON CHANGE', but how?

Regards
Rafael Perez
User avatar
IMATECH
Posts: 188
Joined: Sun May 27, 2012 9:33 pm
Location: Brazil: Goiânia-GO.

Re: Cambiar imágenes en Grid

Post by IMATECH »

Yes: in ON CHANGE event you have to set Column 1 to [0,1]

or try to use

Code: Select all

...
ON CHANGE { || This.Refresh() } 
...

Can you post the code for Grid Create and AddItems ?



Regards
M., Ronaldo

By: IMATECH

Imation Tecnologia
arroya2
Posts: 172
Joined: Thu Aug 06, 2009 7:16 am

Re: Cambiar imágenes en Grid

Post by arroya2 »

Chacal.GO wrote: Yes: in ON CHANGE event you have to set Column 1 to [0,1]

or try to use

Code: Select all

...
ON CHANGE { || This.Refresh() } 
...
Can you post the code for Grid Create and AddItems ?

Regards
Gracias.

El siguiente archivo contiene el Programa que no funciona:
PruebaGrid.zip
(841.83 KiB) Downloaded 349 times
Saludos
Rafael Pérez
Translated by Google:
Thank you.

The following file contains the program does not work:
PruebaGrid.zip
(841.83 KiB) Downloaded 349 times
Regards
Rafael Perez
User avatar
IMATECH
Posts: 188
Joined: Sun May 27, 2012 9:33 pm
Location: Brazil: Goiânia-GO.

Re: Cambiar imágenes en Grid

Post by IMATECH »

Let's try again:

Code: Select all


   DEFINE GRID Grid_1
      ROW      10
      COL      10
      WIDTH   400
      HEIGHT  300 
      HEADERS {'...','Nombre y Apellidos', 'Status' } 
      WIDTHS  { 20, 300, 70}
      VALUE   { 1, 1 }
      IMAGE   { 'Led_On.Bmp' ,'Led_Off.Bmp' }
      JUSTIFY { GRID_JTFY_LEFT, GRID_JTFY_LEFT, GRID_JTFY_LEFT } 
      FONTCOLOR {0,0,255}
      ONDBLCLICK SelecDes()
      MULTISELECT .F.
      ROWSOURCE 'Test'
      COLUMNFIELDS { 'IIF(Test->Married,1,0)', 'Rtrim(Test->First)+" - "+Rtrim(Test->Last)', 'IIF(Test->Married,"Si","No")' }
   END GRID


Add after any table data change

SelecDes(),SelecTodos() and DesSelecTodos()

wTablaAviso.Grid_1.Refresh()


Regards
M., Ronaldo

By: IMATECH

Imation Tecnologia
arroya2
Posts: 172
Joined: Thu Aug 06, 2009 7:16 am

Re: Cambiar imágenes en Grid

Post by arroya2 »

M. Ronaldo thank you very much, everything is solved.

Regards
Rafael Perez
Post Reply