Results 1 to 7 of 7

Thread: How to change the cell background of a specific grid cell

  1. #1

    How to change the cell background of a specific grid cell

    Hi,

    I have a grid bound to a table in a custom VFP Section.
    As users fulfill different actions, I need to be able to change the color of specific cell backgrounds.

    I know the cell I want, how do change the backcolor programmaticly ?
    I have looked at Dynamic Cell Background, but this is not based on a table value.

    would it be something along of the line of

    sCell = namespace.grid.item(x,y)
    sCell.backcolor='red'

    Thanks

    Herb

  2. #2
    Lianja MVP
    Join Date
    Feb 2012
    Location
    Berea, KY, USA
    Posts
    2,185
    Have you tried:

    sCell.backcolor={myfunction()}

    Hank

  3. #3
    Hi Hank,

    No Luck there either.

    Herb

  4. #4
    Junior Member
    Join Date
    Jul 2017
    Posts
    1
    Quote Originally Posted by hmischel@diligentsystems.com View Post
    Hi Hank,

    No Luck there either.

    Herb
    You can use iif Statements on dynamic cell background, check grid formatting example.

    double click on section attributes at the dynamic cell background you'll see

    iif(employeeid=1,"lightgreen","")

    or Employee ID column

    dynamic cell background = iif( {} = 4, "red", "")
    dynamic cell foreground = iif( {} = 4, "yellow", "")



    I hope this helps.

  5. #5
    Hi Luisc,

    That works on a standard grid object.

    In my case, I am using a custom VFP section and hand creating all of my objects.

    Meaning - in my code, I use addobject(), so the attributes need to be exposed on a programmatic level.


    Thanks

    Herb

  6. #6
    Lianja Team yvonne.milne's Avatar
    Join Date
    Feb 2012
    Location
    Berkshire, UK
    Posts
    1,842
    Hi Herb,

    As far as I am aware, you can access the backcolor and forecolor of the column, but not an individual cell.

    Grid.item(x,y) returns the text from a cell, not an object reference to the cell.

    Maybe worth an enhancement request, since as you say columns in standard Grid Sections have the 'Cell dynamic background' and 'Cell dynamic foreground' attributes.

    Regards,

    Yvonne

  7. #7
    Hi Yvonne,

    Will do.

    Herb

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Journey into the Cloud
Join us