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

Grid1.setall() ???? 1

Status
Not open for further replies.

ellehcsim

Programmer
Dec 9, 2003
16
0
0
PH
hi experts,

is it possible to change the font color of a specific column (not the whole row, just a record in one of the columns) depending on a certain condition.

ive already tried this command but it didn't work.

thisform.grid1.column4.setall("dynamicforecolor",IIF(orders.qty_on_hand = 0,255,0))

if ever, can you please state how.

thank you very much.!
 
Grid.Init Event:
PUBLIC Xno

Grid1.AfterRowColChange Event:
ThisForm.Grid1.Column1.DynamicFontBold="IIF(RECNO()=Xno, RGB(255,255,0), RGB(192,192,192))"
ThisForm.Grid1.Refresh
 
hi.!

the code didn't actually work, but it gave me an idea.

i got it working with this one..

ThisForm.grd1.Column4.DynamicForeColor = IIF(itemdetails_pr.qty_apprvd=0,"255","0")

Thanks KONUK! you did great!
 
ellehcsim,

The problem with your SetAll code is that you need to put the condition in quotes. If you don't, the condition will be evaluated at the time that you execute the SetAll, and the result of that evaluation will be stored in the DynamicBackColor property, which is not what you want. You want to store the condition itself, that is, the IIF() function, in the property.

Mike


Mike Lewis
Edinburgh, Scotland
 
Hi

A sample Search Form.
faq184-2858

This form also confirms the point. When the focus is put to the buttons, hold the mouse on the buttons without releasing it and see the colors are OK.

:)

____________________________________________
ramani - (Subramanian.G) :)
When you ask VFP questions, please add VFP version.
 
HI

My post is not meant for this thread, though it appears related. Just ignore that and I am not answering since it is resolved. :)

____________________________________________
ramani - (Subramanian.G) :)
When you ask VFP questions, please add VFP version.
 
sorry for the untidy reply, the code must be like following:

Grid1.AfterRowColChange Event:
Xno=RECNO()
ThisForm.Grid1.Column1.DynamicFontBold="IIF(RECNO()=Xno, .t.,.f.)"
ThisForm.Grid1.Refresh

 
This works for me.
Grid1 init event

THIS.Column1.DynamicForeColor = ;
"IIF(EOF('ACH'),RGB(255,0,0),RGB(0,0,0))"
 
ellehcsim,

There are actually a couple of problems with your original code. First, as Mike pointed out, you need quotes around the expression when you set it in code. But you're calling the Column4 SETALL method, which would set the DynamicForeColor for anything contained in the column--not the column itself. Since nothing but the column itself has that property, the command didn't do anything. This is why using
Code:
ThisForm.grd1.Column4.DynamicForeColor = [IIF(itemdetails_pr.qty_apprvd=0,"255","0")]
works. (Although that's not really the best way to set colors. Using RGB(255,0,0) or RGB(0,0,0) would be better.)



-BP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top