StringGrid Cell Colors 
Author Message
 StringGrid Cell Colors

I need to colour specific rows of cells in a StringGrid based on the
text value in the column. can anyone help? I only seem to be able to
colour the whole grid or nothing.



Wed, 18 Jun 1902 08:00:00 GMT  
 StringGrid Cell Colors


Quote:
>I need to colour specific rows of cells in a StringGrid based on the
>text value in the column. can anyone help? I only seem to be able to
>colour the whole grid or nothing.

You should write the OnDrawCell event handler and use the methods of
Canvas object, as shown in example below (C++ Builder code):

void __fastcall TForm1::StringGrid1DrawCell(TObject *Sender, int Col,
      int Row, TRect &Rect, TGridDrawState State)
{
  if (Row == 2) {
    TStringGrid *sg = (TStringGrid *)Sender;
    sg->Canvas->Font->Color = clRed;
    sg->Canvas->FillRect(Rect);
    sg->Canvas->TextOut(Rect.Left+2, Rect.Top+2, sg->Cells[Col][Row]);
  }

Quote:
}

Demidov Dmitry.
Moscow, Russia.


Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Finding the Top, Left, etc of a StringGrid.Cell or DBGrid.Field

2. DELPHI: Can you change row color in StringGrid?

3. Color in StringGrid

4. color a cell in a DBGRID???

5. Separate colors for each TStringGrid cell

6. Colors in cells on DBgrid ?

7. Changing font color of DbGrid cell.

8. Applying colors to individual cells in a grid

9. How to change DBGrid text color in a single cell

10. Changing cell color ??

11. Coloring cells...

12. A Dbgrid with colored cells ?

 

 
Powered by phpBB® Forum Software