Solved

different colours of Stringgrid cells

Posted on 1999-01-14
3
314 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 100 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

840 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