Solved

DBGrid in d3

Posted on 1998-02-09
2
186 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
  • 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
TcomboBox uninverted item 3 45
delphi exception 7 58
delphi parse string to params 3 82
control image tags in a string ? 12 68
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…
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…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

746 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now