Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How do I dynamically change one cell in a grid?
Message
 
 
To
09/08/2001 16:59:18
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00542012
Message ID:
00542027
Views:
14
>Nadya-
>
>>If there are bunch of cases, create a method of your form, called MyColor
>>column1.DynamicBackColor="thisform.myColor(MyTable.MyField)"
>>
>>and put this code into MyColor method:
>>
>>lparameter tValue
>>local lnColor
>>do case
>>   case tValue=x
>>       lnColor=rgb(....) && Red
>>   case tValue=y
>>       lnColor=rgb(...) && Blue
>>    etc...
>>endcase
>>return m.lnColor
>
>I'm being dense about something. When I try something like this:
>
>
*!* Temp.MyGetColor()
>LPARAMETERS tvValue
>DO CASE
>	CASE tvValue = "31011     "
>		ln = RGB(255,0,0)
>	CASE tvValue = "31036     "
>		ln = RGB(128,255,0)
>	OTHERWISE
>		ln = RGB(128,0,128)
>ENDCASE
>RETURN ln
>
>I get an error. The error depends how I've set the dynamicbackcolor property. However, neither way works. The indication it's an invalid value for the property. What am I doing wrong?
>
>If I set th property like so =thisform.GetMyColor(EVAL(this.controlsource)), method executes as I expect but when it returns I get the error: Error loading file...DynamicBackColor: Data type is invalid for this property
>
>If I set the property as you suggest: thisform.GetMyColor(EVAL(this.controlsource)) I get Expression is invalid. Use a valid expression for DYNAMICBACKCOLOR property and the method is not even called.
>

I doubt, you can do it from the property sheet, if it's what you meant. I allways do it in a code... and you should surround the whole expression with quotes.
>Neither works, of course.

Thisform.MyColor(MyTable.myField) should be in quotes. I have it working just fine in couple of projects. In some I use external program called myColor, in the recent one I added a new method to the grid class (not the form, though it doesn't matter) and it also works. Here is the code from my grid class:
Init:
dodefault()
this.setall('DynamicForeColor', "this.myforecolor(BldMstr."+thisform.AddrField+")", 'Column')
    * .Setall('Sparse',.F.)
set message to thisform.caption
and here is the MyForeColor method of the grid:
********************************************************************
*  Description.......: grdAddrStd.myForeColor - sets grid's forecolor depending on Status field value
*  Calling Samples...: 
*  Parameter List....: 
*  Created by........: Nadya Nosonovsky 06/29/01 11:31:54 PM 
*  Modified by.......: 
********************************************************************
lparameter tcFieldVal
local lnColor
if vartype(m.tcFieldVal)"C"
   tcFieldVal=evaluate('BldMstr.'+thisform.AdddrField)
endif   
* --     changed the fore color of the whole row 
* --     red = auto suspect 
* --     blue = manually resolve 
* --     green auto-correct 
* --     highlight the selected line light blue ... 
*--------------------------------------------------------------------------
local lnColor
do case
    case m.tcFieldVal='5'
         lnColor=rgb(255,0,0) && Auto-suspect
    case m.tcFieldVal='4'
         lnColor=rgb(0,128,0) && Auto-correct    

    case m.tcFieldVal='6' && Manually-resolved
         lnColor=rgb(0,0,255)
    otherwise
         lnColor=rgb(0,0,0) && Black
endcase
return m.lnColor
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform