Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Changing Grid HighlightBackColor dynamically
Message
From
11/09/2007 18:00:13
James Blackburn
Qualty Design Systems, Inc.
Kuna, Idaho, United States
 
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Environment versions
Visual FoxPro:
VFP 9
Miscellaneous
Thread ID:
01253689
Message ID:
01253802
Views:
27
Hi Paul,

I made a couple of adjustments and this seems to work for me.
oForm = CREATEOBJECT([form1])
oForm.Show(1)

DEFINE CLASS form1 AS form


    DoCreate = .T.
    Caption = "Form1"
    Name = "Form1"


    ADD OBJECT grid1 AS mygrid WITH ;
        Height = 200, ;
        Left = 12, ;
        Top = 8, ;
        Width = 320, ;
        HighlightStyle = 2, ;
        Name = "Grid1"
        AllowCellSelection = .F.


    PROCEDURE Load
        CREATE CURSOR crsTest (Fld1 int, Fld2 C(20))

        INSERT INTO crsTest VALUES (1, "1")
        INSERT INTO crsTest VALUES (1, "1")
        INSERT INTO crsTest VALUES (2, "2")
        INSERT INTO crsTest VALUES (2, "2")
        INSERT INTO crsTest VALUES (2, "2")
        INSERT INTO crsTest VALUES (3, "3")
        INSERT INTO crsTest VALUES (3, "3")                                        

        GO TOP
    ENDPROC


    PROCEDURE Init
        thisform.Grid1.SetAll([DynamicBackColor],[thisform.SetGridColor()],[Column])
    ENDPROC


    PROCEDURE setgridcolor
        LOCAL lnDynColor, lnHghLghtColor

        IF Fld1 = 2
           lnDynColor = RGB(183, 255, 124)
           *// lnHghLghtColor = RGB(183, 255, 124)
        ELSE
           lnDynColor = RGB(255, 255, 255)
           *// lnHghLghtColor = RGB(236, 233, 218)
        ENDIF
        *// thisform.Grid1.HighlightBackColor = lnHghLghtColor
        RETURN lnDynColor
    ENDPROC
    
ENDDEFINE

DEFINE CLASS mygrid AS grid
		PROCEDURE afterrowcolchange
			LPARAMETERS nColindex 
			DODEFAULT(nColindex)
	      IF Fld1 = 2
           lnHghLghtColor = RGB(183, 255, 124)
        ELSE
           lnHghLghtColor = RGB(236, 233, 218)
        ENDIF
        thisform.Grid1.HighlightBackColor = lnHghLghtColor
		ENDPROC 

ENDDEFINE 
>>>>
>>>>Try this (I didn't :o))
>>>
>>>Unfortunately, no, it doesn't work.
>>
>>That works for me:
>
>When I tried it, it appeared to work. But then as I started adding more records to my test it appeared to be evaluating a different record than the current one.
>
>Try this code and notice that it doesn't work correctly:
>
>
>oForm = CREATEOBJECT([form1])
>oForm.Show(1)
>
>DEFINE CLASS form1 AS form
>
>
>    DoCreate = .T.
>    Caption = "Form1"
>    Name = "Form1"
>
>
>    ADD OBJECT grid1 AS grid WITH ;
>        Height = 200, ;
>        Left = 12, ;
>        Top = 8, ;
>        Width = 320, ;
>        HighlightStyle = 2, ;
>        Name = "Grid1"
>        AllowCellSelection = .F.
>
>
>    PROCEDURE Load
>        CREATE CURSOR crsTest (Fld1 int, Fld2 C(20))
>
>        INSERT INTO crsTest VALUES (1, "1")
>        INSERT INTO crsTest VALUES (1, "1")
>        INSERT INTO crsTest VALUES (2, "2")
>        INSERT INTO crsTest VALUES (2, "2")
>        INSERT INTO crsTest VALUES (2, "2")
>        INSERT INTO crsTest VALUES (3, "3")
>        INSERT INTO crsTest VALUES (3, "3")
>
>        GO TOP
>    ENDPROC
>
>
>    PROCEDURE Init
>        thisform.Grid1.SetAll([DynamicBackColor],[thisform.SetGridColor()],[Column])
>    ENDPROC
>
>
>    PROCEDURE setgridcolor
>        LOCAL lnDynColor, lnHghLghtColor
>
>        IF Fld1 = 2
>           lnDynColor = RGB(183, 255, 124)
>           lnHghLghtColor = RGB(183, 255, 124)
>        ELSE
>           lnDynColor = RGB(255, 255, 255)
>           lnHghLghtColor = RGB(236, 233, 218)
>        ENDIF
>        thisform.Grid1.HighlightBackColor = lnHghLghtColor
>        RETURN lnDynColor
>    ENDPROC
>
>
>ENDDEFINE
>
Previous
Reply
Map
View

Click here to load this message in the networking platform