BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

highlight dbgrid rows

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (Desktop)
View previous topic :: View next topic  
Author Message
Nick Iorio
Guest





PostPosted: Fri Jan 09, 2004 8:17 pm    Post subject: highlight dbgrid rows Reply with quote




I want to selectively highlight - set background to a color - specific rows in a dbgrid based on the value of a column in the grid. I'm using Delphi 5.
TIA - nick

Back to top
Wayne Niddery [TeamB]
Guest





PostPosted: Fri Jan 09, 2004 10:56 pm    Post subject: Re: highlight dbgrid rows Reply with quote



Nick Iorio wrote:
Quote:
I want to selectively highlight - set background to a color -
specific rows in a dbgrid based on the value of a column in the grid.
I'm using Delphi 5. TIA - nick

The following example will work on any table with a 'salary' field such as
the employee.db table in DBDEMOS.

procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
DataCol: Integer; Column: TColumn; State: TGridDrawState);
begin
if Table1.FieldByName('salary').AsFloat > 40000 then
DBGrid1.Canvas.Brush.Color := clYellow
else
DBGrid1.Canvas.Brush.Color := clWindow;
// override for selected
if gdSelected in State then
DBGrid1.Canvas.Brush.Color := clHighlight;
DbGrid1.DefaultDrawColumnCell(Rect,DataCol, Column, State);
end;

--
Wayne Niddery - Logic Fundamentals, Inc. (www.logicfundamentals.com)
RADBooks: http://www.logicfundamentals.com/RADBooks.html
"It is error alone which needs the support of government. Truth can
stand by itself." - Thomas Jefferson



Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (Desktop) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.