Page 1 of 2
GRID with image help
Posted: Wed Jun 11, 2014 2:04 pm
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
Re: GRID with image help
Posted: Wed Jun 11, 2014 2:55 pm
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
Re: GRID with image help
Posted: Wed Jun 11, 2014 3:31 pm
by maaupe
Obrigado pela resposta mas columwhen nao e para validação. Desculpe nao entendi
Re: GRID with image help
Posted: Wed Jun 11, 2014 3:34 pm
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
Re: GRID with image help
Posted: Wed Jun 11, 2014 5:18 pm
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
Re: GRID with image help
Posted: Wed Jun 11, 2014 7:21 pm
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
Re: GRID with image help
Posted: Wed Jun 11, 2014 8:39 pm
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
Re: GRID with image help
Posted: Wed Jun 11, 2014 10:06 pm
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
Re: GRID with image help
Posted: Wed Jun 11, 2014 10:16 pm
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
Re: GRID with image help
Posted: Wed Jun 11, 2014 10:26 pm
by maaupe
thanks vagblad.
undestand but i use status char(1) and array index is numeric
status = 'P' or ='A'
dinamcDysplay ?
best regards
good night
Marcos