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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can button color be varied across records in a VFP grid? 2

Status
Not open for further replies.

dsandlin

Programmer
Jul 11, 2003
56
CR
I have a spec that calls for a grid with a command button in one column. The color of the button needs to vary with certain conditions. I have tried making fields in the recordsource cursor that contain desired fore- and background colors and then setting the backcolor property for the button to "=curSrc.BackColor" and likewise for the forecolor property. I am able to get a desired initial color (same for all records), but when I use the normal method to change cursor values, nothing happens. By normal, I mean:

lcSavSrc = form.pgf.page1.grid.recordsource
form.pgf.page1.grid.recordsource = ''
REPLACE curSrc.BackColor WITH 255
form.pgf.page1.grid.recordsource = lcSavSrc

Can you suggest a solution?

Thanks, Dick [bigears]
 
Hi Dick,

Look at the help and example for DynamicBackColor and DynamicForeColor properties.

Jim
 


Faq184-1939 describes how to use dynamicCurrentcontrol based on a condition, you can use the same example but replace the texboxes for commandbuttons.

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
I have never tried using DynamicBackColor or DynamicForeColor with command buttons, but I've a sneaky suspicion they won't work (someone prove me wrong, by all means).

However, Mike G's suggestion of having two command buttons, each with different colours, and using DynanicCurrentControl to switch between them sounds promising.

Mike


Mike Lewis
Edinburgh, Scotland

My Visual Foxpro web site: My Crystal Reports web site:
 
There is no dynamicforecolor/dynamicbackcolor for the command buttons (in VFP6) - in fact there isn't even a backcolor - I don't know about 7 and onwards.

But if you use a set of 'images' of a number of buttons, then the DynamicCurrentControl you could mimic the effect quite easily - although the grid refresh will slow a little



Regards

Griff
Keep [Smile]ing
 
Jim,

Thanks a million! That worked great for me.

I'm still trying to understand what happened. Is it true that the dynamicfore- (and back-) colors for the column object effect all objects in the column? It changed the properties of the button in the column and not the column itself. Container-object properties are a little mysterious to me. But it did what I wanted!

Thanks again, Dick [sunshine]

 
Griff,

There is no dynamicforecolor/dynamicbackcolor for the command buttons

True. But that applies to all controls. The Dynamicxxx properties belong to the column objects.

in fact there isn't even a backcolor - I don't know about 7 and onwards.

Backcolor for buttons came in in 8.0, to the delight of many but the mild teeth-gnashing of a few die-hards like me.

Mike


Mike Lewis
Edinburgh, Scotland

My Visual Foxpro web site: My Crystal Reports web site:
 
Mike, Mike, and Griff,

Yes, I know that there is no dynamicbackcolor property for the individual controls. That is what confused me. Jim's point, which is proven out in my application, is that those dynamic properties apply to the container object, in this case the column object of the grid. Modifying the properties of the container object modifies all the objects in the container, in this case the command button. I think that I learned something today! I wish that I could give Jim another star for that!


Regards, Dick [wavey]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top