Lazarus

Programming => Graphics and Multimedia => Graphics => Topic started by: jbmckim on September 12, 2020, 09:48:38 pm

Title: Coloring a stringgrid cell background(solved)
Post by: jbmckim 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?
Title: Re: Coloring a stringgrid cell background
Post by: wp 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.
Title: Re: Coloring a stringgrid cell background
Post by: jbmckim on September 15, 2020, 11:04:26 pm
Outstanding.  Thanks.
TinyPortal © 2005-2018