如何可以控制DBGrid中的每个单元格,比如在特定的单元格上绘图,背景色等等??
解决方案 »
- 为什么把windows api这个版块放在delphi这里。。。
- Delphi的USB通信問題
- 简单问题!!!关于bsskinchecklistbox1
- 我是新手,请教关于dbgrid的问题
- 【paradox】的数据库谁有比较简单些的还原备份数据的例子?因为不想将备份和主程序分开。所以拷贝复制的办法不行。
- QRCompositeReport控制纸张大小设置问题
- 急救:DELPHI如何处理大数据量的数据库?
- SqlServer2000+BDE为什么不能执行FILTER?
- 100分等大家来拿哟!!!!(急急急。。。。。。。。。。。。)
- 如何在程序中自动获取 本机的机器名和ip地址
- 在每列中插入不同的数据的sql怎么写?急!!!!
- 请问有没有可以*** 免费拨打国际长途的软件?***
DataCol: Integer; Column: TColumn; State: TGridDrawState);
begin
// if Column.Index = 0 then //列判断
// if Column.Field.DataSet.RecNo then //行判断
if Random(2) = 0{ TODO : 条件成立 } then begin
TDBGrid(Sender).Canvas.FillRect(Rect);
TDBGrid(Sender).Canvas.Font.Color := clRed;
end;
TDBGrid(Sender).DefaultDrawColumnCell(Rect, DataCol, Column, State);
end;
procedure TForm2.DBGrid1DrawColumnCell(Sender: TObject;
const Rect: TRect; DataCol: Integer;
Column: TColumn; State: TGridDrawState);
var
DrawBitmap : boolean ;
begin
with Sender as TDBGrid do begin
if Table1State.Value = 'HI' then begin
Canvas.Brush.Color := clYellow ;
if gdSelected in State then begin
Canvas.Font.Color := clBlack ;
Canvas.Font.Style := Canvas.Font.Style + [fsBold] ;
end ;
DrawBitmap := (Column.FieldName = 'Company') ;
end
else
DrawBitmap := False ;
Canvas.FillRect(Rect) ;
if DrawBitmap then begin
{ if your bitmap is too large, you
should investigate StretchDraw
rather than Draw }
Canvas.Draw(Rect.Left, Rect.Top, MyBitmap) ;
Canvas.TextOut(Rect.Left + MyBitmap.Width + 5, Rect.Top,
Column.Field.AsString) ;
end
else
Canvas.TextOut(Rect.Left, Rect.Top,
Column.Field.AsString) ;
end ;
end ;