TStringGrid中实现网格单元Hint功能

翻译|其它|编辑:郝浩|2006-07-03 11:22:00.000|阅读 1418 次

概述:

# 界面/图表报表/文档/IDE等千款热门软控件火热销售中 >>

TStringGrid中虽然具有Hint功能,但却是为整个控件设置的,网格的单元并不具备Hint功能。本文介绍一种利用OnMouseMove事件来实现网格单元Hint功能的代码,具体如下:
 
 TForm1 = class(TForm)
   StringGrid1: TStringGrid;
   procedure FormCreate(Sender: TObject);
   procedure StringGrid1MouseMove(Sender: TObject; Shift: TShiftState; X,
     Y: Integer);
 private
   FRect: TRect;
   { Private declarations }
 public
   { Public declarations }
 end;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
 SetRect(FRect, 0, 0, 0, 0);
end;
 
procedure TForm1.StringGrid1MouseMove(Sender: TObject;
 Shift: TShiftState; X, Y: Integer);
var
 Pt: TPoint;
 Col, Row: integer;
begin
 StringGrid1.MouseToCell(x, y, Col, Row);
 Pt.X := x;
 Pt.Y := y;
 if not PtInRect(FRect, Pt) then
 begin
   FRect := StringGrid1.CellRect(Col, Row);
   Inc(FRect.Right);
   Inc(FRect.Bottom);
   StringGrid1.Hint := StringGrid1.Cells[Col, Row];
   Application.CancelHint;
 end;
end;

end.
标签:

本站文章除注明转载外,均为本站原创或翻译。欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,如果存在内容上的异议请邮件反馈至chenjj@evget.com


为你推荐

  • 推荐视频
  • 推荐活动
  • 推荐产品
  • 推荐文章
  • 慧都慧问
扫码咨询


添加微信 立即咨询

电话咨询

客服热线
023-68661681

TOP