GRID with image help

HMG Samples and Enhancements

Moderator: Rathinagiri

maaupe
Posts: 7
Joined: Fri May 17, 2013 1:53 pm

GRID with image help

Post by maaupe »

how to use grid with image : in my app i use :
@ 56,10 GRID grid_1 ;
WIDTH 290 ;
HEIGHT 660 ;
HEADERS {'...','RECIBO' } ;
IMAGE {'\icones\bmp\pago.BMP','\icones\bmp\aberto.BMP'} ;
WIDTHS { 50, 200 } ;
ROWSOURCE "COBRANCA" ;
COLUMNFIELDS { VERIFICAIMAGE() ,'COBRANCA->ANO+COBRANCA->MES+COBRANCA->CODIMOVEL' } ;
JUSTIFY { GRID_JTFY_CENTER, GRID_JTFY_CENTER } ;
//DYNAMICDISPLAY { val(VERIFICAIMAGE()), { || This.CellValue} } ;
ON CHANGE Atualizar() //refresh controls the form



static Function VERIFICAIMAGE()
Local nIndice:=0


If PAGO == 'P'
/*em DIA*/
nIndice:=0
Endif

iF PAGO == 'A'
/*em atraso*/
nIndice:=1
Endif


how to use image in this case.


thanks

Marcos
User avatar
Amarante
Posts: 182
Joined: Fri Apr 27, 2012 9:44 pm
DBs Used: DBF, MySQL, MariaDB, SQLite, PostgreSQL
Location: Araruama-RJ, Brazil

Re: GRID with image help

Post by Amarante »

--------------- Portugues
No meu caso Eu uso COLUMNWHEN porque o usuário pode mudar a imagem com o double click do mouse, mas depende do que você quer fazer
-----------------------English
In my case I use COLUMNWHEN because the user can change the image with the double click of the mouse, but it depends what you want to do
maaupe
Posts: 7
Joined: Fri May 17, 2013 1:53 pm

Re: GRID with image help

Post by maaupe »

Obrigado pela resposta mas columwhen nao e para validação. Desculpe nao entendi
maaupe
Posts: 7
Joined: Fri May 17, 2013 1:53 pm

Re: GRID with image help

Post by maaupe »

Eu so gostaria de a cada linha carregada exibir um icone .
Seo o status da fatura estivar paga exibir um icone verde
se o staus da fatura nao estiver paga exibir icone vermelho.


espero ter conseguido explicar, mas muito obrigado pela atenção
User avatar
vagblad
Posts: 160
Joined: Tue Jun 18, 2013 12:18 pm
DBs Used: MySQL,DBF
Location: Thessaloniki, Greece

Re: GRID with image help

Post by vagblad »

Hello maaupe,

If i understood correctly what you wanna do, here is how i do it with Grid control:

Code: Select all

DEFINE GRID Grid_1
	     ROW    10
        COL    10
        WIDTH  530
        HEIGHT 500
        ITEMS {{ "","", "", "", "" }}
        WIDTHS { 20,100, 100, 150, 100 }
        HEADERS { "", "Invoice No.", "Date", "Supplier", "Value" }
        FONTNAME 'Arial'
        FONTSIZE 12
        TOOLTIP ''
        IMAGE { 'GREEN.BMP' ,'RED.BMP' }
        JUSTIFY { BROWSE_JTFY_CENTER, BROWSE_JTFY_RIGHT,  BROWSE_JTFY_RIGHT, BROWSE_JTFY_RIGHT, BROWSE_JTFY_LEFT }
END GRID
Inside the IMAGE { } you put the image files you want to use. In my case i used 2 files.
Notice that i have left the 1st column of the grid empty.

Add items to the grid control like this:

Code: Select all

MainForm.Grid_1.AddItem({ 0, "1234", "10/6/2014", "Supplier 1", "1200.20" })
MainForm.Grid_1.AddItem({ 1, "1235", "11/6/2014", "Supplier 2", "800.45"  })
In the above example the grid at row 1,col1 will have the Green.bmp and at row 2,col 1 will have the Red.bmp.
It's all about the values in the 1st column. 0 and 1

I hope it helps
Best Regards
Vag

P.S.: I forgot to say that you can see an excellent example of grid and images at : \SAMPLES\Controls\Grid\GRID_19
Vagelis Prodromidis
Email: vagblad@gmail.com, Skype: vagblad
maaupe
Posts: 7
Joined: Fri May 17, 2013 1:53 pm

Re: GRID with image help

Post by maaupe »

Thank you. Vagblad
I can not do this by loading the grid from a table?

using rowsource?

only through an array?

\ samples \ gri.xx only with array

rowsource without using images.

thank you

im sorry idont speak english very well

Marcos
User avatar
vagblad
Posts: 160
Joined: Tue Jun 18, 2013 12:18 pm
DBs Used: MySQL,DBF
Location: Thessaloniki, Greece

Re: GRID with image help

Post by vagblad »

Maaupe try this:

Code: Select all

#include "hmg.ch"

FUNCTION Main


DEFINE WINDOW Form_1 ;
	AT 0,0 ;
	WIDTH 800 ;
	HEIGHT 600 ;
	TITLE 'Grid And Dbf With Status Images' ;
	MAIN 

	USE TEST  

	GO TOP

	DEFINE GRID Grid_1
		ROW   10
		COL   10	
		WIDTH 770 
		HEIGHT 440 
		HEADERS {'Status', 'First','Last','Invoice','Date','Supplier','Money'} 
		WIDTHS {50,140,140,100,100,100,100}
		ROWSOURCE "Test" 
		IMAGE { 'green.bmp', 'red.bmp' }
		COLUMNFIELDS { 'status', 'firstname' ,  'lastname' , 'invoiceno' ,  'date' , 'supplier' , 'money' } 
		JUSTIFY { BROWSE_JTFY_CENTER, BROWSE_JTFY_LEFT, BROWSE_JTFY_LEFT, BROWSE_JTFY_RIGHT, BROWSE_JTFY_CENTER, BROWSE_JTFY_LEFT, BROWSE_JTFY_RIGHT }
	END GRID 
	
END WINDOW

CENTER WINDOW Form_1

ACTIVATE WINDOW Form_1

RETURN
I am attaching the example files also. (With the 2 images needed and the simple .dbf file i used)

Feel free to ask if you want any more help
Best Regards
Vag
Attachments
Example.zip
(1.27 MiB) Downloaded 372 times
Vagelis Prodromidis
Email: vagblad@gmail.com, Skype: vagblad
EduardoLuis
Posts: 682
Joined: Tue Jun 04, 2013 6:33 pm
Location: Argentina

Re: GRID with image help

Post by EduardoLuis »

Hi Vagblad:

I've download your example, and my surprise becomes when i execute your exe: no readable data of the table.- I attach the screen.-
Do you have the same result.-
Thanks for your answer.-
With regards. Eduardo
Attachments
SCREEN_OF_EXAMPLE.jpg
SCREEN_OF_EXAMPLE.jpg (87.98 KiB) Viewed 6072 times
User avatar
vagblad
Posts: 160
Joined: Tue Jun 18, 2013 12:18 pm
DBs Used: MySQL,DBF
Location: Thessaloniki, Greece

Re: GRID with image help

Post by vagblad »

EduardoLuis wrote:Hi Vagblad:

I've download your example, and my surprise becomes when i execute your exe: no readable data of the table.- I attach the screen.-
Do you have the same result.-
Hi Eduardo,

Very strange. Try putting the Example folder inside the hmg\samples folder and run the build.bat again.
Because the .exe works fine on me.

I tested mine at the following path: C:\hmg.3.3.0\SAMPLES\Example\build.bat

Please if you can try it and tell me if it works.

Best Regards
Vag
Vagelis Prodromidis
Email: vagblad@gmail.com, Skype: vagblad
maaupe
Posts: 7
Joined: Fri May 17, 2013 1:53 pm

Re: GRID with image help

Post by maaupe »

thanks vagblad.

undestand but i use status char(1) and array index is numeric ;)
:cry:

status = 'P' or ='A'

dinamcDysplay ?

best regards

good night

Marcos
Post Reply