Solved

color in a row of a dbgrid

Posted on 1998-04-18
4
410 Views
Last Modified: 2010-04-06
we are using dbgrid's and we need paint diferent rows with different colors how can I do it ?
0
Comment
Question by:jaldana
[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
4 Comments
 
LVL 5

Accepted Solution

by:
inter earned 50 total points
ID: 1335011
Hi,
The simples way is to obtain the  RxLib Delphi component package and use their RXDBgrid(The package contains dozens of very useful components). It has several other capabilites over DBGrid and is FREE. You can download it from:

  http://rx.demo.ru/files/index.html or
direcly
 http://rx.demo.ru/files/rxlib240.zip

USE IT, YOU WILL BE SATISFIED

Regards,
Igor
0
 
LVL 5

Expert Comment

by:julio011597
ID: 1335012
What about an OwnerDraw'ed DBGrid?
It is not that hard, IMO.
0
 
LVL 5

Expert Comment

by:inter
ID: 1335013
Fine,
Thats one way, however, can not simply compete with RxLib(it takes time I mean). Any way julio is right.
Regards,
Inter
0
 

Expert Comment

by:schappel
ID: 1335014
Sure the simplest way of doing something is to use what somebody
else has written, but that dowsn't teach you anything.

I would suggest that you use an OwnerDrawGrid.  All you have to
do is the following:
 Change the DefaultDrawing property of the DBGrid to False

 Add Some code to the OnDrawColumnCell (*Use this one as
 OnDrawDataCell is supposed to obsolete *)
 e.g.
procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
  DataCol: Integer; Column: TColumn; State: TGridDrawState);
begin
  if Table1.FieldByName('ItemsTotal').Value > 10000 then
  begin
    // Change the line to be bold for lines with above ^^
    DBGrid1.Canvas.Font.Style := [fsBold];  
    if Column.FieldName = 'ItemsTotal' then
      // Change the Color to red for the ItemsTotalColumn if
      // the prior condition is met
      DBGrid1.Canvas.Font.color := clRed;
  end;

  // Call the default drawing now as all we have done is changed
  // the color of thins.  If we wanted to draw in different
  // styles like 3D tehn we would have to handle that aswell
  DBGrid1.DefaultDrawColumnCell( Rect, DataCol, Column, State );
end;


hope this helps

Scott
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
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 Month8 days, 8 hours left to enroll

617 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