Solved

DBGrid in d3

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying 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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

688 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