Solved

different colours of Stringgrid cells

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
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…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

770 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