在线等待!!!!!! 200分,急求关于dxDGRrid的一个问题的解决方法. ( 积分: 200 )

  • 主题发起人 主题发起人 taizhi
  • 开始时间 开始时间
T

taizhi

Unregistered / Unconfirmed
GUEST, unregistred user!
假如有一个表<br>&nbsp;&nbsp;IsInit&nbsp;Boolean;<br>&nbsp;&nbsp;Selected:Boolean;<br>&nbsp;&nbsp;BookName:String;<br>该表用dxDBGrid来显示数据,我想当Selected值为True时,IsInit的检测框的颜色为红色,否则为clWhite,即白色.该如何写代码?
 
补充一句,是检测框的填充颜色,而不是TdxDBGridCheckColumn.Color
 
借助贴子问个问题!先说声谢谢[:)]<br>把dataset里面的数据导出到excel如果数据比较多的时侯是不是只有用jet连接到excel里导入是最快的方法?
 
procedure&nbsp;TForm1.BitBtn11Click(Sender:&nbsp;TObject);<br>&nbsp;var&nbsp;v:variant;<br>sheet:variant;<br>str:string;<br>i,j,z,a:integer;<br>begin<br>v:=createoleobject('Excel.Application');<br>v.visible:=false;<br>v.workbooks.open(extractfilepath(application.ExeName)+'3050周销售报表(各处).xls');//添加工作表<br>sheet:=v.sheets['部门'];<br>v.sheets['部门'].activate;<br>adoquery5.First&nbsp;;<br>{while&nbsp;not&nbsp;adoquery1.Eof&nbsp;do<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sheet.Cells.Item[i,1]:=&nbsp;adoQuery1.FieldByName('销售额').AsVariant&nbsp;;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sheet.Cells.Item[i,2]:=&nbsp;adoQuery1.FieldByName('毛利率').AsVariant;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sheet.Cells.Item[i,3]:=&nbsp;adoQuery1.FieldByName('总库存').Asinteger;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sheet.Cells.Item[i,4]:=&nbsp;adoQuery1.FieldByName('周转率').Asfloat;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sheet.Cells.Item[i,5]:=&nbsp;adoQuery1.FieldByName('处名称').Asstring;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sheet.Cells.Item[i,6]:=&nbsp;adoQuery1.FieldByName('date').AsString;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;adoquery1.Next;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;i:=i+1;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;&nbsp;}<br>//a:=adoquery5.RecordCount&nbsp;div&nbsp;5;<br>i:=3;<br>while&nbsp;not&nbsp;adoquery5.Eof&nbsp;do<br>&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for&nbsp;j:=2&nbsp;to&nbsp;22&nbsp;do<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;z:=j;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sheet.Cells.Item[i,z]:=&nbsp;adoQuery5.FieldByName('销售额').AsVariant&nbsp;;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;z:=j+21;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sheet.Cells.Item[i,z]:=&nbsp;adoQuery5.FieldByName('毛利率').AsVariant;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;adoquery5.Next;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;inc(i);<br>&nbsp;&nbsp;&nbsp;end;<br><br>&nbsp;i:=3;<br>&nbsp;adoquery8.First&nbsp;;<br>&nbsp;adoquery9.First&nbsp;;<br>&nbsp;while&nbsp;not&nbsp;adoquery8.Eof&nbsp;do&nbsp;begin<br>&nbsp;for&nbsp;j:=1&nbsp;to&nbsp;5&nbsp;do<br>&nbsp;begin<br>&nbsp;sheet.Cells.Item[i,43+j]:=&nbsp;adoQuery9.FieldByName('毛利率').Asfloat&nbsp;;<br>&nbsp;adoquery9.Next&nbsp;;<br>&nbsp;end;<br>&nbsp;sheet.Cells.Item[i,1]:=&nbsp;adoQuery8.FieldByName('date').Asstring&nbsp;;<br>&nbsp;inc(i);<br>&nbsp;adoquery8.Next;<br>&nbsp;end;&nbsp;&nbsp;&nbsp;<br><br>像这样的如果导出的数据少的话还可以,多的话太慢了。有没有可以快一点的方法?
 
怎么没有一个人回答呢?难道很难吗?帮顶者另外送分!
 
if&nbsp;dxDBGrid.DataSource.DataSet.FieldByName('IsInit&nbsp;').values&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dxDBGrid.Canvas.Brush.Color&nbsp;:=&nbsp;clBLACK;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dxDBGrid.Canvas.FillRect(Rect);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dxDBGrid.DefaultDrawColumnCell(Rect,DataCol,Column,State);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end<br>&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dxDBGrid.Canvas.Brush.Color&nbsp;:=&nbsp;clBLACK;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dxDBGrid.Canvas.FillRect(Rect);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dxDBGrid.DefaultDrawColumnCell(Rect,DataCol,Column,State);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;
 
该段代码写到哪个事件中去呢?
 
DrawColumnCell
 
是CustomDrawCell吗?这个控件可没有DrawColumnCell哦!
 
你的代码执行不了?你没测试过?
 
用数据库呀!
 
to&nbsp;hwj112<br>用数据库?能否说详细点呢?
 
建议楼主可以查阅下DEV&nbsp;EXPRESS控件的帮助文档,也有一些demo可以看的。dxDBGrid具体的控制在OnCustomDrawCell,里面有ACanvas,直接进行画图处理。你可以给全局的统一配置,或者你针对每个CEll分别处理。还有,可以建议你使用CxGrid,这个控制也不错,只是需要你对控件属性了解颇多。
 
可以寫在GETTEXT裏面。那樣可以實現。我有做過。代碼。一時想不起來。等我回家再發給你吧。
 
后退
顶部