Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

different colours of Stringgrid cells

Posted on 1999-01-14
3
Medium Priority
?
319 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
ID: 1356564
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 400 total points
ID: 1356565
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
ID: 1356566
Test was great - thanks
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

972 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