Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > DB-Aware

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 08-10-2003, 09:20 PM
nora_tt nora_tt is offline
Member
 
Join Date: Jun 2003
Posts: 42
Default set different color of dbgrid

hi,everyone:
step 1:
in dbgrid ,defaultdrawing property is false.
step 2:
set State property of Columns is csDefault.
step 3:
in DBGrid1DrawDataCell event, coding follow:
================================================== =========
var
mycolumn:tcolumn;
begin
DBGrid1.Columns.Clear;
mycolumn:=DBGrid1.Columns.Add;
mycolumn.Alignment:=taCenter;
mycolumn.FieldName:=MyFieldName;
mycolumn.Title.Caption:=MyColCaption;
mycolumn.Title.Alignment:=taCenter;
...
end;

but the main problem is i cannot see the result values,e.g
select * from mytable=====>the result is more than one record.(maybe 3 record counts)

in dbgrid,i cannot see the result value in every cell,
row count is right(above e.g 3)
Reply With Quote
  #2  
Old 08-10-2003, 09:23 PM
nora_tt nora_tt is offline
Member
 
Join Date: Jun 2003
Posts: 42
Default RE: set different color of dbgrid

my intention is selected row color is other than non_selected row color.
selected row color is yellow
non_selected row color is default
Reply With Quote
  #3  
Old 08-10-2003, 10:28 PM
Sylvestre Sylvestre is offline
Senior Member
 
Join Date: Mar 2003
Posts: 116
Default RE: set different color of dbgrid

try this :

procedure MyForm.MyDBGridDrawColumnCell(Sender: TObject;const Rect: TRect; DataCol: Integer; Column: TColumn;State: TGridDrawState);
begin
if gdSelected in State then
MyDBGrid.Canvas.Brush.Color := clYellow

MyDBGrid.DefaultDrawColumnCell(Rect,DataCol,Column ,State);
end;


Sylvestre
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 12:54 AM.


Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2019, vBulletin Solutions, Inc.