?
Solved

DBGrid in d3

Posted on 1998-02-09
2
Medium Priority
?
193 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 400 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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses
Course of the Month10 days, 15 hours left to enroll

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