关于DBgrid的语句,急!!! ( 积分: 50 )

  • 主题发起人 主题发起人 chcsl
  • 开始时间 开始时间
C

chcsl

Unregistered / Unconfirmed
GUEST, unregistred user!
我是这样做的,&nbsp;在&nbsp;Form1&nbsp;上放置&nbsp;DBGrid1、ADOQuery1、DataSource1<br>不能通过编译,请高手指点,加下划线处请解释一下。&nbsp;<br>语句如下:<br>procedure&nbsp;TMainForm.DBGrid1DrawColumnCell(Sender:&nbsp;TObject;<br>const&nbsp;Rect:&nbsp;TRect;&nbsp;DataCol:&nbsp;Integer;&nbsp;Column:&nbsp;TColumn;State:&nbsp;TGridDrawState);<br>var&nbsp;i&nbsp;:integer;<br>begin<br>if&nbsp;gdSelected&nbsp;in&nbsp;State&nbsp;then&nbsp;Exit;<br>//定义表头的字体和背景颜色:<br>&nbsp;&nbsp;&nbsp;for&nbsp;i&nbsp;:=0&nbsp;to&nbsp;(Sender&nbsp;as&nbsp;TDBGrid).Columns.Count-1&nbsp;do<br>&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(Sender&nbsp;as&nbsp;TDBGrid).Columns.Title.Font.Name&nbsp;:='宋体';&nbsp;//字体<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(Sender&nbsp;as&nbsp;TDBGrid).Columns.Title.Font.Size&nbsp;:=9;&nbsp;//字体大小<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(Sender&nbsp;as&nbsp;TDBGrid).Columns.Title.Font.Color&nbsp;:=$000000ff;&nbsp;//字体颜色(红色)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(Sender&nbsp;as&nbsp;TDBGrid).Columns.Title.Color&nbsp;:=$0000ff00;&nbsp;//背景色(绿色)<br>&nbsp;&nbsp;&nbsp;end;<br>//隔行改变网格背景色:<br>if&nbsp;ADOQuery1.RecNo&nbsp;mod&nbsp;2&nbsp;=&nbsp;0&nbsp;then<br>&nbsp;&nbsp;&nbsp;(Sender&nbsp;as&nbsp;TDBGrid).Canvas.Brush.Color&nbsp;:=&nbsp;clInfoBk&nbsp;//定义背景颜色<br>else<br>&nbsp;&nbsp;&nbsp;(Sender&nbsp;as&nbsp;TDBGrid).Canvas.Brush.Color&nbsp;:=&nbsp;RGB(191,&nbsp;255,&nbsp;223);&nbsp;//定义背景颜色<br>//定义网格线的颜色:<br>&nbsp;&nbsp;&nbsp;DBGrid1.DefaultDrawColumnCell(Rect,DataCol,Column,State);<br>with&nbsp;(Sender&nbsp;as&nbsp;TDBGrid).Canvas&nbsp;do&nbsp;//画&nbsp;cell&nbsp;的边框<br>begin<br>&nbsp;&nbsp;&nbsp;Pen.Color&nbsp;:=&nbsp;$00ff0000;&nbsp;//定义画笔颜色(蓝色)<br>&nbsp;&nbsp;&nbsp;MoveTo(Rect.Left,&nbsp;Rect.Bottom);&nbsp;//画笔定位<br>&nbsp;&nbsp;&nbsp;LineTo(Rect.Right,&nbsp;Rect.Bottom);&nbsp;//画蓝色的横线<br>&nbsp;&nbsp;&nbsp;Pen.Color&nbsp;:=&nbsp;$0000ff00;&nbsp;//定义画笔颜色(绿色)<br>&nbsp;&nbsp;&nbsp;MoveTo(Rect.Right,&nbsp;Rect.Top);&nbsp;//画笔定位<br>&nbsp;&nbsp;&nbsp;LineTo(Rect.Right,&nbsp;Rect.Bottom);&nbsp;//画绿色的竖线<br>end;<br>end;
 
gdSelected &nbsp;<br>&nbsp;&nbsp;The&nbsp;cell&nbsp;is&nbsp;currently&nbsp;selected.<br><br>Sender&nbsp;as&nbsp;TDBGrid<br>&nbsp;&nbsp;类型转换。
 
我用的是D7,为什么不能通过编译
 
好象没什么错的,我的能通过<br>通不过的编译信息呢?
 
语句没错,你只要从新写一遍就可以了。或者将语句前的空格去掉后重新再加空格。
 
后退
顶部