Solved

DBGrid in d3

Posted on 1998-02-09
2
191 Views
Last Modified: 2010-04-04
How do i change a (non selected) row's color in a DBGrid component?

How can I do this automatically, based on a specific field's value?

e.g. I want all employee's records in an grid to be shown in red if the employee is a manager.
0
Comment
Question by:kyriacos
[X]
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
  • 2
2 Comments
 
LVL 5

Expert Comment

by:ronit051397
ID: 1358808
The row in red or the font in red?
0
 
LVL 5

Accepted Solution

by:
ronit051397 earned 100 total points
ID: 1358809
Connect the DBGrid to the COUNTRY.DB from the DBDEMOS and write the following:


procedure TForm1.DBGrid1DrawDataCell(Sender: TObject; const Rect: TRect;
  Field: TField; State: TGridDrawState);
begin
  if not (gdSelected in State) then
  with DBGrid1.Canvas do
  begin
    if Table1.FieldbyName('Continent').Value='North America' then
    begin
      brush.Color:=clRed;
      font.Color:=clWhite;
    end
    else
    begin
      brush.Color:=clWhite;
      font.Color:=clBlack;
    end;
      FillRect(Rect);
      TextOut(Rect.Left,Rect.Top,Field.Value);
  end;
end;
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi component that can load a DLL in design time? 8 93
Delphi 2 77
delphi parse string to params 3 158
Firemonkey Queue list 1 33
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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
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 antispam), the admini…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

696 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