请教一个问题,我能改变DBGrid控件中一个单元格的颜色吗?并在一些单元格中加图片。
解决方案 »
- 动态过程写法
- outlook获取邮件收件人
- **急求:Webservice系统中服务端CGI程序如何取得客户端的IP?
- 程序中使用了TFrame作为子窗口,想在主窗口尺寸改变时TFrame能随主窗口而改变尺寸...在线等...
- 怎样获得窗体左上角 在 屏幕中的位置??(TPoint)
- 改变默认1433为1435 bde 连接不上sqlserver
- Tform.show 和Tform.showmodul() 有啥区别?
- (问)运行server端报错“有另一版本的DBLogDlg已经编译”。
- 那位老兄知道哪儿有DBTreeView的控件(提供源码),或有相关网站。
- 点击一个Treeview1时、能在多个edit中分别显示各值?
- 谁打印DBGrid代码?不使用其他控件????
- 如何在多线程中使用ADO?
procedure TfrmJBXX.DBGrid3DrawColumnCell(Sender: TObject;
const Rect: TRect; DataCol: Integer; Column: TColumn;
State: TGridDrawState);
var i:integer;
ARect:TRect;
iIndex:integer;
begin
inherited;
//变色
with sender as TDBGRID do
begin
i:=datasource.DataSet.RecNo mod 2;
if i=0 then canvas.Brush.Color:= dbgLittle//颜色
else Canvas.Brush.Color:=dbgHeave;//颜色
if (gdSelected in State) or (gdFocused in state) then
begin
Canvas.Brush.Color:= dbgSelect;//颜色
Canvas.Font.Color:= dbgSelectFont;//颜色
end;
defaultdrawcolumncell(rect,datacol,column,state);
//画图
if Column.Field.FieldName ='flags' then
begin
iIndex:=Column.Field.asInteger;
if (iIndex>=2) or (iIndex<0) then iIndex:=0;
canvas.FillRect(rect);
img2.Draw(canvas,rect.left+((Rect.Right-Rect.Left-img2.Width) div 2),rect.top,iIndex);
end;
end;end;
begin
if column.field=table单元格对应的字段 then
if table1.fieldbyname('单元格对应的字段').asvariant=此单元格的值
then
dbgrid1.canvas.font.color:=clred;//或其他颜色 由你写
dbgrid1.defaultdrawdatacell(rect,column,field,state);
end;
ondrawcolumncell里写