Board index » delphi » ? about Delphi3 grid - row color and cell color

? about Delphi3 grid - row color and cell color

Hello -

Does anyone know how to, if possible:
  1) change color of a particular row (vs. column) on a DBgrid;
  2) change color of a particular cell in a row on a DBgrid;
  3) make the background or the text of a particular row to flash
     a certain color (ie. red to white, then back to red).

Perhaps there is another standard Delphi component to be used.
......................................

Thanks much and TIA (thanks in advance), William

Please reply to: will...@juno.com
               or to: awill...@aol.com

 

Re:? about Delphi3 grid - row color and cell color


AWillRed <awill...@aol.com> wrote in article
<1998062102143400.WAA15...@ladder03.news.aol.com>...

Quote
> Does anyone know how to, if possible:
>   1) change color of a particular row (vs. column) on a DBgrid;

assign an event handler to the OnDrawCell event. Arguments are the row and
column index of the cell to be drawn as well as the rect of the cell. Then
use the canvas of the grid to set the brush colour and fill the rect +
write the text in the rect. First check if the cell is in the row you want
to colour.

Quote
>   2) change color of a particular cell in a row on a DBgrid;

similar to the above.

Quote
>   3) make the background or the text of a particular row to flash
>      a certain color (ie. red to white, then back to red).

never tried this one. I would try the following approach:
1. make a private field or so to hold the rect of the cell(s) you want to
flash
2. use the OnDrawCell event to get the rect of the cell(s) in question
3. use a timer to toggle the colour at a frequency of your choice
4. use the OnTopLeftChanged event to check if the cell in question still is
visible. You can use properties like VisibleRowCount and TopRow for this.
If the cell in question is not visible, stop the timer. Like: if TopRow >
MyRow or TopRow+VisibleRowCount-1 < MyRow then ...

Quote

> Perhaps there is another standard Delphi component to be used.

check out the following delphi sites:

http://www.torry.ru
http://sunsite.informatik.rwth-aachen.de/delphi/
http://www.penzberg.de/homepages/helpmakers/index.html

Wim

Other Threads