dbgrid背景显示颜色问题 ( 积分: 100 )

  • 主题发起人 主题发起人 gao_ad
  • 开始时间 开始时间
G

gao_ad

Unregistered / Unconfirmed
GUEST, unregistred user!
inherited;<br>&nbsp;&nbsp;if&nbsp;&nbsp;AXLData.SQL_cus_ite_pro_ADOQ.FieldByName('是否质保期').Value&nbsp;=&nbsp;'是'&nbsp;&nbsp;&nbsp;then<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;DBGridEh5.Canvas.Font.Color&nbsp;&nbsp;:=&nbsp;clRed;<br>&nbsp;&nbsp;&nbsp;&nbsp;DBGridEh5.Canvas.Brush.Color:=clYellow;//clGradientActiveCaption;<br>&nbsp;&nbsp;end;<br>&nbsp;&nbsp;DBGridEh5.DefaultDrawColumnCell(Rect,DataCol,Column,State);<br>出错&nbsp;错误提示:Incompatible&nbsp;types
 
无inherited;时正常
 
inherited是继承窗体
 
AXLData.SQL_cus_ite_pro_ADOQ.FieldByName('是否质保期').Value&nbsp;=&nbsp;'是'<br>这个类型有问题吗?&nbsp;&nbsp;AsString?
 
没问题<br>这句:DBGridEh5.DefaultDrawColumnCell(Rect,DataCol,Column,State);<br>有问题
 
DefaultDrawColumnCell(Rect,DataCol,Column,State)<br>可能DBGRID的这个函数引起的,LZ的DLEPHI版本有变化没?最好重新放置EH控件!
 
好像D6的放到D7就会引起这问题,应该是控件改变了!
 
重新放置了也不行&nbsp;但是如果窗体不继承就没问题
 
好像不是窗体继承吧?是EH继承?<br>问题在继承就看看继承和没继承有什么区别咯!
 
procedure&nbsp;TCustomDBGridEh.DefaultDrawColumnCell(const&nbsp;Rect:&nbsp;TRect;<br>&nbsp;&nbsp;DataCol:&nbsp;Integer;&nbsp;Column:&nbsp;TColumnEh;&nbsp;State:&nbsp;TGridDrawState);<br>var<br>&nbsp;&nbsp;Value:&nbsp;string;<br>&nbsp;&nbsp;ARect,&nbsp;ARect1:&nbsp;TRect;<br>&nbsp;&nbsp;XFrameOffs,&nbsp;YFrameOffs,&nbsp;KeyIndex:&nbsp;Integer;<br>begin<br>&nbsp;&nbsp;ARect&nbsp;:=&nbsp;Rect;<br>&nbsp;&nbsp;if&nbsp;(dghFooter3D&nbsp;in&nbsp;OptionsEh)&nbsp;then<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;XFrameOffs&nbsp;:=&nbsp;1;<br>&nbsp;&nbsp;&nbsp;&nbsp;InflateRect(ARect,&nbsp;-1,&nbsp;-1);<br>&nbsp;&nbsp;end&nbsp;else&nbsp;XFrameOffs&nbsp;:=&nbsp;2;<br>&nbsp;&nbsp;YFrameOffs&nbsp;:=&nbsp;XFrameOffs;<br>&nbsp;&nbsp;if&nbsp;Flat&nbsp;then&nbsp;Dec(YFrameOffs);<br>&nbsp;&nbsp;Value&nbsp;:=&nbsp;Column.DisplayText;<br><br>&nbsp;&nbsp;if&nbsp;Column.GetColumnType&nbsp;in&nbsp;[ctCommon..ctKeyPickList]&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;WriteTextEh(Canvas,&nbsp;ARect,&nbsp;True,&nbsp;XFrameOffs,&nbsp;YFrameOffs,&nbsp;Value,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Column.Alignment,&nbsp;tlTop,&nbsp;Column.WordWrap&nbsp;and&nbsp;FAllowWordWrap,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Column.EndEllipsis,&nbsp;0,&nbsp;0,&nbsp;UseRightToLeftReading)<br>&nbsp;&nbsp;else&nbsp;if&nbsp;Column.GetColumnType&nbsp;=&nbsp;ctKeyImageList&nbsp;then<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;Canvas.FillRect(ARect);<br>&nbsp;&nbsp;&nbsp;&nbsp;KeyIndex&nbsp;:=&nbsp;Column.KeyList.IndexOf(Column.Field.Text);<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;KeyIndex&nbsp;=&nbsp;-1<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;then&nbsp;KeyIndex&nbsp;:=&nbsp;Column.NotInKeyListIndex;<br>&nbsp;&nbsp;&nbsp;&nbsp;DrawClipped(Column.ImageList,&nbsp;nil,&nbsp;Canvas,&nbsp;ARect,&nbsp;KeyIndex,&nbsp;0,&nbsp;taCenter);<br>&nbsp;&nbsp;end&nbsp;else&nbsp;if&nbsp;Column.GetColumnType&nbsp;=&nbsp;ctCheckboxes&nbsp;then<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;Canvas.FillRect(ARect);<br>&nbsp;&nbsp;&nbsp;&nbsp;ARect1.Left&nbsp;:=&nbsp;ARect.Left&nbsp;+&nbsp;iif(ARect.Right&nbsp;-&nbsp;ARect.Left&nbsp;&lt;&nbsp;DefaultCheckBoxWidth,&nbsp;0,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(ARect.Right&nbsp;-&nbsp;ARect.Left)&nbsp;shr&nbsp;1&nbsp;-&nbsp;DefaultCheckBoxWidth&nbsp;shr&nbsp;1);<br>&nbsp;&nbsp;&nbsp;&nbsp;ARect1.Right&nbsp;:=&nbsp;iif(ARect.Right&nbsp;-&nbsp;ARect.Left&nbsp;&lt;&nbsp;DefaultCheckBoxWidth,&nbsp;ARect.Right,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ARect1.Left&nbsp;+&nbsp;DefaultCheckBoxWidth);<br>&nbsp;&nbsp;&nbsp;&nbsp;ARect1.Top&nbsp;:=&nbsp;ARect.Top&nbsp;+&nbsp;iif(ARect.Bottom&nbsp;-&nbsp;ARect.Top&nbsp;&lt;&nbsp;DefaultCheckBoxHeight,&nbsp;0,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(ARect.Bottom&nbsp;-&nbsp;ARect.Top)&nbsp;shr&nbsp;1&nbsp;-&nbsp;DefaultCheckBoxHeight&nbsp;shr&nbsp;1);<br>&nbsp;&nbsp;&nbsp;&nbsp;ARect1.Bottom&nbsp;:=&nbsp;iif(ARect.Bottom&nbsp;-&nbsp;ARect.Top&nbsp;&lt;&nbsp;DefaultCheckBoxHeight,&nbsp;ARect.Bottom,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ARect1.Top&nbsp;+&nbsp;DefaultCheckBoxHeight);<br><br>&nbsp;&nbsp;&nbsp;&nbsp;//DrawCheck(Canvas.Handle,ARect1,Column.CheckboxState,True,Flat);<br>&nbsp;&nbsp;&nbsp;&nbsp;PaintButtonControl&nbsp;{Eh}(Canvas.Handle,&nbsp;ARect1,&nbsp;Canvas.Brush.Color,&nbsp;bcsCheckboxEh,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0,&nbsp;Flat,&nbsp;False,&nbsp;True,&nbsp;Column.CheckboxState);<br>&nbsp;&nbsp;end;<br><br>&nbsp;&nbsp;//WriteTextEh(Canvas,&nbsp;ARect,&nbsp;True,&nbsp;XFrameOffs,&nbsp;YFrameOffs,&nbsp;Value,&nbsp;Column.Alignment,tlTop,Column.WordWrap&nbsp;and&nbsp;FAllowWordWrap,&nbsp;Column.EndEllipsis,0,0);<br>end;<br>-----------------------------------------------------------------------<br>procedure&nbsp;TCustomDBGrid.DefaultDrawColumnCell(const&nbsp;Rect:&nbsp;TRect;<br>&nbsp;&nbsp;DataCol:&nbsp;Integer;&nbsp;Column:&nbsp;TColumn;&nbsp;State:&nbsp;TGridDrawState);<br>var<br>&nbsp;&nbsp;Value:&nbsp;string;<br>begin<br>&nbsp;&nbsp;Value&nbsp;:=&nbsp;'';<br>&nbsp;&nbsp;if&nbsp;Assigned(Column.Field)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;Value&nbsp;:=&nbsp;Column.Field.DisplayText;<br>&nbsp;&nbsp;WriteText(Canvas,&nbsp;Rect,&nbsp;2,&nbsp;2,&nbsp;Value,&nbsp;Column.Alignment,<br>&nbsp;&nbsp;&nbsp;&nbsp;UseRightToLeftAlignmentForField(Column.Field,&nbsp;Column.Alignment));<br>end;
 
帮你顶一个,接个分
 
忘记问LZ,你的代码是写在什么时间里?
 
后退
顶部