>>Close Databases All >>Create Table tpolicy (po_number c(25), po_name c(20), po_status c(3)) >>Insert Into tpolicy Values ("John T. Smith","123456","CXP") >>Insert Into tpolicy Values ("Sally A. Taylor","789012","NB") >>Insert Into tpolicy Values ("Craig Abernathy","AAB123","REN") >>Insert Into tpolicy Values ("Chris Johnson","890123","AP") >> >>Create Table vstatus (st_status c(3), st_attrib i) >>Insert Into vstatus Values ("CXP",Rgb(255,128,192)) >>Insert Into vstatus Values ("NB",Rgb(255,255,0)) >>Insert Into vstatus Values ("AP",Rgb(128,255,255)) >>Close Databases All >> >>Public oForm >>oForm = Createobj('testform') >>oForm.Show() >> >>Define Class testform As Form >> DataSession = 2 >> Height = 227 >> Width = 461 >> DoCreate = .T. >> Caption = "Test Highlight Change " >> gridbackcolor = Rgb(0,128,192) >> gridforecolor = Rgb(0,0,0) >> >> Add Object grid1 As Grid With ; >> ColumnCount = 3, Height = 200, Left = 24, ; >> RecordSource = "tpolicy", Top = 12, Width = 410 >> >> Procedure Load >> Use tpolicy In 0 >> Endproc >> >> Procedure Init >> DoDefault() >> This.AddProperty('_vStatus[1]') >> This.AddProperty('_vType[1]','') >> Select st_status, st_attrib ; >> FROM vstatus ; >> WHERE !(st_status == '') ; >> into Array This._vstatus >> Use In 'vstatus' >> With This.grid1 >> .SetAll('SelectedBackColor', This.gridbackcolor) >> .SetAll('SelectedForeColor', This.gridforecolor) >> .Column1.ControlSource = "tpolicy.po_number" >> .Column2.ControlSource = "tpolicy.po_status" >> .Column3.ControlSource = "tpolicy.po_name" >> .Column1.Header1.Caption = "po_number" >> .Column2.Header1.Caption = "po_status" >> .Column3.Header1.Caption = "po_name" >> Endwith >> This.SetPolicyGridColor() >> Endproc >> >> Procedure SetPolicyGridColor >> Local nColumnID >> With This.grid1 >> For nColumnID = 1 To .ColumnCount >> With .Columns(nColumnID) >> .DynamicBackColor = "(thisform.GetPolicyGridColor('"+.ControlSource+"'))" >> Endwith >> Endfor >> Endwith >> Endproc >> >> Procedure getpolicygridcolor >> Lparameters tcControlSource >> Local defaultcolorvalue,lcColorField, luValue, lnColorRow >> With Thisform.grid1 >> defaultcolorvalue = Iif(Recno(.RecordSource) = .nCurrec,This.gridbackcolor,0xFFFFFF) >> Endwith >> tcolorfield = Upper(Justext(m.tcControlSource)) >> >> If Type(m.tcControlSource) = 'G' >> Return m.defaultcolorvalue >> Endif >> luValue = Evaluate(m.tcControlSource) >> >> Do Case >> Case tcolorfield == "PO_SUSP" Or tcolorfield == "PO_STATUS" >> lnColorRow = Ascan(This._vstatus, m.luValue, 1,-1,1,2+4+8) >> Return Iif(m.lnColorRow > 0, This._vstatus[m.lnColorRow,2], m.defaultcolorvalue ) >> Case tcolorfield = "PO_TYPE" >> lnColorRow = Ascan(This._vtype, m.luValue, 1,-1,1,2+4+8) >> Return Iif(m.lnColorRow > 0, This._vtype[m.lnColorRow,2], m.defaultcolorvalue ) >> Endcase >> Return m.defaultcolorvalue >> Endproc >> >> Procedure grid1.Init >> This.AddProperty('nCurrec',0) >> Endproc >> >> Procedure grid1.BeforeRowColChange >> Lparameters nColIndex >> Thisform.LockScreen = .T. >> Endproc >> >> Procedure grid1.AfterRowColChange >> Lparameters nColIndex >> This.nCurrec = Recno() >> Thisform.LockScreen = .F. >> Endproc >>Enddefine >>Cetin