Subject Re: Row Colours in Grid
From Tim Ward <tim@goldengrovenurserydotcodotuk>
Date Thu, 15 Feb 2018 07:15:07 +0000
Newsgroups dbase.getting-started

On 15/02/2018 01:18, Michael wrote:
> Hi Guys,
>
> Can anyone tell me how I can color specific rows in a grid to highlight different records upon display?
>
> Eg:
>
> Row 1
> Row 2
> Row 3
> Row 4
> Row 5
>
> Rows 1 and 4 can be normal (black/white), Rows 2 and 3 may be White/Brown and row 5 could be say, white/Green.
>
> Is this possible in Dbase 11.
>
> Regards,
>
> Micahel.
>
Hi Michael,
        As ken says it's not quite as simple as colouring 1 row but below are a
few examples of how you can conditionally set the colour of a column.
this refers to form.grid.editorcontrol in the below examples. If you
want all columns to be the same you would have to set each column to use
the same function.

regards Tim

*** Sets the colour of the column based on a value in that column using
a case function

  function editorControl_beforeCellPaint(bSelectedRow)
       Do Case
          Case trim(this.value) = "Add" OR trim(this.value) = "Split"
             this.colorNormal := "Black/0X82EBFD"
          Case trim(this.value) = "Update"
             this.colorNormal := "Black/0x11d8fb"
          Otherwise
             this.colorNormal := "Black/White"
       Endcase
       return true

*** Sets colour if the value of the column is over zero

    function editorControl_beforeCellPaint1(bSelectedRow)
       If len(trim(this.value)) > 0
          this.colorNormal := "Black/White"
       Else
          this.colorNormal := "Black/Red"
       Endif
       return true

*** Sets the colour of this column comparing the value in the column to
values in another columns

    function editorControl_beforeCellPaint2(bSelectedRow)
       If trim(this.value) <>
trim(this.parent.parent.countingdata1.rowset.fields["CurrentLocation"].value)
AND this.parent.parent.countingdata1.rowset.fields["Action"].value =
"Update"
          this.colorNormal := "Black/0X82EBFD"
       Endif

       return true