Solved

different colours of Stringgrid cells

Posted on 1999-01-14
3
309 Views
Last Modified: 2010-04-06
how can i give the choice cells of a stringgrid different
textcolours or background colours ?
0
Comment
Question by:tzigan
3 Comments
 
LVL 20

Expert Comment

by:Madshi
Comment Utility
Hmm. I don't know. Have you looked for extended freeware components?

http://nswt.tuwien.ac.at/delphi/index.htm    (Delphi Super Page)
http://www.torry.ru/       (Torry's Delphi Pages)

Regards, Madshi.
0
 
LVL 3

Accepted Solution

by:
Ronald Buster earned 100 total points
Comment Utility
Hi TZigan,

This is simple just write your own OnDrawCell procedure place a stringgrid on your form
choose events and double click on OnDrawCell event now place for instance following
code :

procedure TForm1.StringGrid1DrawCell(Sender: TObject; Col, Row: Integer;
  Rect: TRect; State: TGridDrawState);
var tr : TRect;
     ts : string;
     te : extended;
begin
   tr := StringGrid1.CellRect(Col, Row);
   if Odd(Row) then
     begin
        with StringGrid1.Canvas do
           begin
              Brush.Color := clBtnFace;
              Font.Color := clNavy;
              Font.Style := [fsBold];
              FillRect(tr);
             TextOut(tr.Left+2, tr.Top+2, StringGrid1.Cells[Col,Row])
          end;
      end
   else
      begin
        with StringGrid1.Canvas do
           begin
              Brush.Color := clBlue;
              Font.Color := clWhite;
              Font.Style := [fsItalic];
              FillRect(tr);
             TextOut(tr.Left+2, tr.Top+2, StringGrid1.Cells[Col,Row])
          end;
      end;
end;


Hope this helps,

regards,

Cono
0
 

Author Comment

by:tzigan
Comment Utility
Test was great - thanks
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now