Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Change Grid Highlight to Match column dynamicbackcolor
Message
De
09/09/2005 09:41:25
 
 
À
08/09/2005 16:45:07
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Divers
Thread ID:
01047867
Message ID:
01048075
Vues:
19
I got it working.


>I am having problems with this. I set the dynamicbackcolor of a column in a grid based on the value in the cell. This part works fine. However, when the row is highlighted, you cannot see the dynamicbackcolor of the cell because the entire row is highlighted. I need to change the highlight in the cell with the dynamicbackcolor to the same value. Is there a simple example of doing this anywhere? Nick Neklioudov's Grid Highlighter Demo Form does demonstrate this, but I am having a very difficult time making it work on my form. Nick's works with the class dropped on the form and fixed values in class properties. I must be dense, because I cannot make this work on my form. My form has the following:
>
>form object name: ofrmprofile
>pageframe = pgfprofile
>page = pagpolicy
>grid = policygrid
>
>ofrmprofile.pgfprofile.pagpolicy.policygrid.column2.sparse = .f. && column with dynamicbackcolor
>ofrmprofile.pgfprofile.pagpolicy.policygrid.column2.dynamicbackcolor = [a conditional expression]
>
>The above all works. The grid properties are:
>
>HighlightBackColor = 0,0,255
>HighlightStyle = 2 - current row highlighting enabled with visual persistence
>
>Now, how to change the highlightbackcolor to the column's dynamicbackcolor when the row is highlighted and then set it back when another row is highlighted? And only have the cell with a special dynamicbackcolor take on the new highlight color? Even just the highlight forecolor in the cell would be nice. In effect, the result would be that the row would be highlighted with the default highlight value of 0,0,255 in all cells except when the cell (column) has a special dynamicbackcolor. Everything is working now (my cell backcolor changes to match the value in the field or that specific cell using the conditional statement above) except for showing it when the row is highlighted.
>
>
>Here is a working example showing the dynamicbackcolor in the cells on the form working but also how the dynamicbackcolor of the column does not show through the highlight color:
>

>
>set safety OFF
>set talk OFF
>set exact ON
>set near OFF
>CLOSE TABLES all
>CLOSE DATABASES all
>
>CREATE TABLE tpolicy(po_number c(25), po_status c(3))
>APPEND BLANK
>REPLACE po_number WITH "123456"
>REPLACE po_status WITH "CXP"
>APPEND BLANK
>REPLACE po_number WITH "789012"
>REPLACE po_status WITH "NB"
>APPEND BLANK
>REPLACE po_number WITH "890123"
>REPLACE po_status WITH "AP"
>sele 0
>CREATE TABLE vstatus (st_status c(3), st_attrib c(16))
>APPEND BLANK
>REPLACE st_status WITH "CXP"
>REPLACE st_attrib WITH "RGB(255,128,192)"
>APPEND BLANK
>REPLACE st_status WITH "NB"
>REPLACE st_attrib WITH "RGB(255,255,0)"
>APPEND BLANK
>REPLACE st_status WITH "AP"
>REPLACE st_attrib WITH "RGB(124,24,32)"
>
>COPY TO ARRAY _vstatus FIELDS ST_STATUS, ST_ATTRIB FOR !EMPTY(ST_STATUS)
>
>*oform = creatobj('testform')
>DO FORM testform NAME oform LINKED
>
>oform.show()
>oform.SetPolicyGridColor
>oform.refresh()
>
>
>
>read events
>
>CLOSE ALL
>return
>
>DEFINE CLASS testform AS form
>
>
>   Top = 0
>   Left = 0
>   Height = 227
>   Width = 717
>   DoCreate = .T.
>   Caption = "Test Highlight Change "
>   Name = "TESTFORM"
>
>
>   ADD OBJECT grid1 AS grid WITH ;
>      ColumnCount = 2, ;
>      Height = 200, ;
>      Left = 24, ;
>      Panel = 1, ;
>      RecordSource = "tpolicy", ;
>      RecordSourceType = 1, ;
>      Top = 12, ;
>      Width = 410, ;
>      HighlightBackColor = RGB(0,0,160), ;
>      HighlightForeColor = RGB(255,255,0), ;
>      HighlightStyle = 2, ;
>      Name = "grid1", ;
>      Column1.ControlSource = "tpolicy.po_number", ;
>      Column1.Width = 154, ;
>      Column1.Name = "Column1", ;
>      Column2.ControlSource = "tpolicy.po_status", ;
>      Column2.Name = "Column2"
>
>
>   ADD OBJECT testform.grid1.column1.header1 AS header WITH ;
>      Caption = "po_number", ;
>      Name = "Header1"
>
>
>   ADD OBJECT testform.grid1.column1.text1 AS textbox WITH ;
>      BorderStyle = 0, ;
>      Margin = 0, ;
>      ForeColor = RGB(0,0,0), ;
>      BackColor = RGB(255,255,255), ;
>      Name = "Text1"
>
>
>   ADD OBJECT testform.grid1.column2.header1 AS header WITH ;
>      Caption = "po_status", ;
>      Name = "Header1"
>
>
>   ADD OBJECT testform.grid1.column2.text1 AS textbox WITH ;
>      BorderStyle = 0, ;
>      Margin = 0, ;
>      ForeColor = RGB(0,0,0), ;
>      BackColor = RGB(255,255,255), ;
>      Name = "Text1"
>
>
>   ADD OBJECT label1 AS label WITH ;
>      BackStyle = 0, ;
>      Caption = ("Note how the dynamicbackcolor "+CHR(13)+"does not show through the highlight. " +CHR(13)+"I need to change the highlight over"+CHR(13)+"the single cell or at least change "+CHR(13)+"the highlight forecolor."), ;
>      Height = 84, ;
>      Left = 502, ;
>      Top = 13, ;
>      Width = 204, ;
>      ForeColor = RGB(255,0,0), ;
>      Name = "Label1"
>
>
>   ADD OBJECT line1 AS line WITH ;
>      BorderWidth = 3, ;
>      Height = 0, ;
>      Left = 411, ;
>      Top = 42, ;
>      Width = 84, ;
>      Name = "Line1"
>
>
>   ADD OBJECT line2 AS line WITH ;
>      BorderWidth = 3, ;
>      Height = 24, ;
>      Left = 407, ;
>      Top = 41, ;
>      Width = 24, ;
>      Name = "Line2"
>
>
>   ADD OBJECT line3 AS line WITH ;
>      BorderWidth = 3, ;
>      Height = 24, ;
>      Left = 406, ;
>      Top = 18, ;
>      Width = 24, ;
>      LineSlant = "/", ;
>      Name = "Line3"
>
>
>   PROCEDURE setpolicygridcolor
>      WITH this.grid1
>         FOR nColumnID = 1 TO .columncount
>            colorvalue = thisform.getpolicygridcolor(.recordsource,.columns(nColumnID).controlsource)
>            .Columns(nColumnID).dynamicbackcolor = colorvalue
>         ENDFOR
>      ENDWITH
>   ENDPROC
>
>
>   PROCEDURE getpolicygridcolor
>      LPARAMETERS tcolortable, tcolorfield
>
>      EXTERNAL ARRAY _vstatus
>      EXTERNAL ARRAY _vtype
>
>      defaultcolorvalue = "RGB(255,255,255)"
>
>      IF EMPTY(tcolortable) .OR. TYPE('tcolortable') <> "C" .OR. !USED(tcolortable)
>         RETURN defaultcolorvalue
>      ENDIF
>      IF TYPE('tcolorfield') <> "C" .OR. EMPTY(tcolorfield)
>         RETURN defaultcolorvalue
>      ENDIF
>      IF AT('.',tcolorfield) > 0
>         tcolorfield = SUBSTR(tcolorfield,AT('.',tcolorfield)+1)
>      ENDIF
>
>      tcolorfield = UPPER(ALLTRIM(tcolorfield))
>
>      SELECT (tcolortable)
>
>      DO CASE
>         CASE tcolorfield = "PO_SUSP"
>            RETURN "IIF(!EMPTY(po_status),IIF(ASCAN(_vstatus,po_status)>0,IIF(!EMPTY(_vstatus(ASCAN(_vstatus,po_status)+1)),EVALUATE(_vstatus(ASCAN(_vstatus,po_status)+1)),RGB(255,255,255)),RGB(255,255,255)),RGB(255,255,255))"
>         CASE tcolorfield = "PO_STATUS"
>            RETURN "IIF(!EMPTY(po_status),IIF(ASCAN(_vstatus,po_status)>0,IIF(!EMPTY(_vstatus(ASCAN(_vstatus,po_status)+1)),EVALUATE(_vstatus(ASCAN(_vstatus,po_status)+1)),RGB(255,255,255)),RGB(255,255,255)),RGB(255,255,255))"
>         CASE tcolorfield = "PO_TYPE"
>            RETURN "IIF(!EMPTY(po_type),IIF(ASCAN(_vtype,po_type)>0,IIF(!EMPTY(_vtype(ASCAN(_vtype,po_type)+2)),EVALUATE(_vtype(ASCAN(_vtype,po_type)+2)),RGB(255,255,255)),RGB(255,255,255)),RGB(255,255,255))"
>      ENDCASE
>
>      RETURN defaultcolorvalue
>   ENDPROC
>
>
>   PROCEDURE Destroy
>      DODEFAULT()
>      CLEAR EVENTS
>   ENDPROC
>
>
>   PROCEDURE Init
>      DODEFAULT()
>   ENDPROC
>
>
>ENDDEFINE
>
>I can see Nick's class setting the highlight forecolor to the column's backcolor but I cannot see how it is actually being done. I have been through the setdynamiccolor() and the highlight_row() methods. I'm feeling pretty stupid today. Any help or small example doing this with a grid on a form would be greatly appreciated.
.·*´¨)
.·`TCH
(..·*

010000110101001101101000011000010111001001110000010011110111001001000010011101010111001101110100
"When the debate is lost, slander becomes the tool of the loser." - Socrates
Vita contingit, Vive cum eo. (Life Happens, Live With it.)
"Life is not measured by the number of breaths we take, but by the moments that take our breath away." -- author unknown
"De omnibus dubitandum"
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform