Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Picture property of command button inside grid

Status
Not open for further replies.

vfpmania

Programmer
Mar 3, 2008
2
I am using the following method in init event of grid to assign the picture property of command button control in the column.

grid's init method:

This.Column9.SetAll("Picture", Iif(Upper(AllTrim(trnhdr01.shipvia)) = "DHL", "tracking\dhl.jpg", "tracking\ups.jpg"), "commandbutton")

But, every row has same picture.
What am I doing wrong?

Thanks.
 
vfpmania

Suggest you assign
Code:
[COLOR=blue]THIS.mBitmapname()[/color]
to the .DynamicCurrentControl property of the column of the grid.

Untested, but in .mBitmapname(), a method you need to add to the grid. put code similar to
Code:
[COLOR=blue]This.Column9.Image1.Picture =  Iif(Upper(AllTrim(trnhdr01.shipvia)) = "DHL", "tracking\dhl.jpg", "tracking\ups.jpg")[/color]
The importance of using the .DynamicCurrentControl property is that you will only render images that are visible in the grid.

FAQ184-2483​
Chris [pc2]
PDFcommander.com
motrac.co.uk
 
VFPMania,

You can't set the Picture that way in the Init. At the time the Init is executed, VFP doesn't know the value of the Shipvia field.

Instead, you should add two buttons to the grid, one with each of the images. Then use DynamicCurrentControl to choose between them.

To save you having to write the same code in both buttons' Click methods, you can use BINDEVENT() to bind them to a commom method elsewhere.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
vfpmania

Apologies for the typo
Code:
[COLOR=blue]This.Column9.Image1.Picture =  Iif(Upper(AllTrim(trnhdr01.shipvia)) = "DHL", "tracking\dhl.jpg", "tracking\ups.jpg")[/color]
should be:-
Code:
[COLOR=blue]This.Column9.Command1.Picture =  Iif(Upper(AllTrim(trnhdr01.shipvia)) = "DHL", "tracking\dhl.jpg", "tracking\ups.jpg")[/color]

FAQ184-2483​
Chris [pc2]
PDFcommander.com
motrac.co.uk
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top