网上文摘 小说 Flash游戏 最近更新 下载排行 资源分类 下载指南
经典编程资源 精彩不容错过
设为首页
加入收藏
联系我们
当前位置:Delphi园地技巧文章控件使用 → DBGrid单元格画圆圈
DBGrid单元格画圆圈
日期:2005年4月15日 作者:jemsn 人气: 查看:[大字体 中字体 小字体]
procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
  DataCol: Integer; Column: TColumn; State: TGridDrawState);
var
  s:String;
begin
  TDBGrid(Sender).DefaultDrawColumnCell(Rect,DataCol,Column,State);
  s:=Column.Field.DisplayText;
  if (Column.FieldName='FAX') and (Length(s)<10) then
  begin
    with TDBGrid(Sender).Canvas do
    begin
      Pen.Color :=clRed;
      Arc(Rect.Left,Rect.Top,Rect.Right,Rect.Bottom,Rect.Left,Rect.Top,Rect.Left,Rect.Top);
    end;
  end;
end;
直接画圆弧就可以了,后面的这种方法只是提供一种参考:
procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
  DataCol: Integer; Column: TColumn; State: TGridDrawState);
const
  Flags:array [TAlignment] of DWORD=(DT_LEFT,DT_RIGHT,DT_CENTER);
var
  s:String;
  R:TRect;
begin
  TDBGrid(Sender).DefaultDrawColumnCell(Rect,DataCol,Column,State);
  s:=Column.Field.DisplayText;
  r:=Rect;
  if (Column.FieldName='FAX') and (Length(s)<10) then
  begin
    with TDBGrid(Sender).Canvas do
    begin
      Pen.Color :=clRed;
      RoundRect(Rect.Left,Rect.Top,Rect.Right,Rect.Bottom,Rect.Left,Rect.Top);
      DrawText(Handle,pchar(s),length(s),R,Flags[Column.Alignment] or DT_VCENTER);
    end;
  end;
end;

bytetype,用于判断某个 Char 是单个字母,还是双字节的前一位或后一位。
mbSingleByte 单字母
mbLeadByte 双字节第一位
mbTrailByte 双字节第二位

ExtractStrings,分割字符串

(出处:www.csdn.net)

相关文章:
·多表头的DBGridEH导出到Excel中
·DBGrid应用全书之定义表格颜色
·打印TDBGrid内容
·自制精美易用的DBGrid
·把DBGrid导出到Excel表格(支持多Sheet)
·隔行改变DBGrid网格颜色
·在Delphi的DBGrid中插入其他可视组件
·锁定DBGrid左边的列
·点击DBGrid的Title对查询结果排序
·去掉DbGrid的自动添加功能
 → 特别推荐
 → 热点TOP10
关于我们 | 广告服务 | 发布资源 | 联系站长 Copyright © 2002-2006 Delphi园地 All Rights Reserved