Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


TStringGrid - color

Posted on 1999-06-27
Medium Priority
Last Modified: 2008-03-06
Is there any way to set the color of an individual cell of a string grid in response to my codes action ie

if.....then cells[2,5]color := clGreen;
Question by:pady
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment

Accepted Solution

ZifNab earned 300 total points
ID: 1384768
Hi Pady,

This is a very simplistic way and will get you further. (It colors the cell 'green' when it contains '4'.

procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
  Rect: TRect; State: TGridDrawState);
var s: string;
  with (Sender as TStringGrid) do
   if Cells[ACol,ARow] = '4' then begin begin
    with Canvas do begin
      if not (gdSelected in state) then {this is not a selected cell}
        brush.Color := clGreen;
        {we draw a color rectangle in the cell}
        {next we need to put the text}
        s:=(Sender as TStringGrid).Cells[ACol,ARow];

Regards, Zif

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

722 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