怎样设置DBGrid标题行、所选记录行的行高度和行背景颜色,所选列宽度

怎样设置DBGrid标题行、所选记录行的行高度和行背景颜色,所选列宽度 Delphi / Windows SDK/API
http://www.delphi2007.net/DelphiDB/html/delphi_20061216115412271.html
rt

1、Columns属性  
   
  2、OnDrawColumnCell事件  
  procedure   TForm1.DBGrid1DrawColumnCell(Sender:   TObject;   const   Rect:   TRect;  
      DataCol:   Integer;   Column:   TColumn;   State:   TGridDrawState);  
  var   i   :integer;  
  begin  
  if   gdSelected   in   State   then   Exit;  
  for   i   :=0   to   (Sender   as   TDBGrid).Columns.Count-1   do  
  begin  
  (Sender   as   TDBGrid).Columns[i].Title.Font.Name   :='宋體';    
  (Sender   as   TDBGrid).Columns[i].Title.Font.Size   :=12;    
  (Sender   as   TDBGrid).Columns[i].Title.Font.Color   :=clNavy;      
  (Sender   as   TDBGrid).Columns[i].Title.Color   :=$00FFC4C4;      
  end;  
  if   query1.RecNo   mod   2   =   0   then  
  (Sender   as   TDBGrid).Canvas.Brush.Color   :=   clInfoBk      
  else  
  (Sender   as   TDBGrid).Canvas.Brush.Color   :=   RGB(191,   255,   223);    
  DBGrid1.DefaultDrawColumnCell(Rect,DataCol,Column,State);  
  with   (Sender   as   TDBGrid).Canvas   do     begin  
  Pen.Color   :=   $00ff0000;      
  MoveTo(Rect.Left,   Rect.Bottom);      
  LineTo(Rect.Right,   Rect.Bottom);      
  Pen.Color   :=   clTeal;      
  MoveTo(Rect.Right,   Rect.Top);      
  LineTo(Rect.Right,   Rect.Bottom);      
  end;  
  end;

行高度怎么设置?标题行高度,记录行高度的设置方法?

posted on 2009-05-12 16:00  delphi2007  阅读(734)  评论(0编辑  收藏  举报