Solved

color in a row of a dbgrid

Posted on 1998-04-18
4
405 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

Suggested Solutions

Title # Comments Views Activity
Printing problem 2 111
Working with hours 3 74
Convert MS Word document to a PDF file 9 115
how to change, disabled button color FMX ? 1 51
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
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…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

726 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