Recent

Author Topic: Coloring a stringgrid cell background(solved)  (Read 1239 times)

jbmckim

  • Full Member
  • ***
  • Posts: 144
Coloring a stringgrid cell background(solved)
« on: September 12, 2020, 09:48:38 pm »
I get using OnPrepareCanvas to change cell color.  I do this successfully in a couple places.

What's confusing me is a slightly different requirement.  I need to allow the user to remove an alarm state (stringgrid cell, red background) from a row by pushing a button. (Going cell by cell is fine. The UI requirement is a column but that can be done cell by cell.)

When this happens, there's no change to the cell value per se, just a change to the background.  Therefore, OnPrepareCanvas doesn't fire.  (The problem only occurs on reset as the initial alarm is thrown in response to a new value being added to the cell in question.)

Therefore, how do I change the background color without modifying cell value?
« Last Edit: September 15, 2020, 11:04:49 pm by jbmckim »

wp

  • Hero Member
  • *****
  • Posts: 11916
Re: Coloring a stringgrid cell background
« Reply #1 on: September 12, 2020, 09:51:32 pm »
Call StringGrid.Invalidate to enforce a redraw of the grid; as a consequence of this OnPrepareCanvas will be called for each cell before it is painted.

jbmckim

  • Full Member
  • ***
  • Posts: 144
Re: Coloring a stringgrid cell background
« Reply #2 on: September 15, 2020, 11:04:26 pm »
Outstanding.  Thanks.

 

TinyPortal © 2005-2018