求教,在DBgrid中如何显示里面记录的其个字段(100)

  • 主题发起人 主题发起人 sd523
  • 开始时间 开始时间
S

sd523

Unregistered / Unconfirmed
GUEST, unregistred user!
在DBgrid中,里面有很多记录,我现在的想法:将鼠标移到某个记录上,就自动显示里面字段的内容,怎么能实现啊
 
除非点击这条记录,否则无法实现或者说实现起来难度很大~
 
TRY: HINT。
 
可以,只是有点麻烦而已。如果调试通过,请给分哦。unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, DB, DBTables, AppEvnts, Grids, DBGrids;type TDBGrid=Class(DBGrids.TDBGrid);//为了访问DataLink属性 TForm1 = class(TForm) DBGrid1: TDBGrid; ApplicationEvents1: TApplicationEvents; Table1: TTable; DataSource1: TDataSource; procedure ApplicationEvents1ShowHint(var HintStr: String; var CanShow: Boolean; var HintInfo: THintInfo); private { Private declarations } public { Public declarations } end;var Form1: TForm1;implementation{$R *.dfm}procedure TForm1.ApplicationEvents1ShowHint(var HintStr: String; var CanShow: Boolean; var HintInfo: THintInfo);Var OldRec:Integer; t:TPoint;begin IF HintInfo.HintControl <> DBGrid1 Then Exit; if not DBGrid1.DataLink.Active then Exit; OldRec:=DBGrid1.DataLink.ActiveRecord; t:=DBGrid1.ScreenToClient( Mouse.CursorPos ); DBGrid1.DataLink.ActiveRecord := (t.Y-20) Div DBGrid1.DefaultRowHeight; HintStr := DBGrid1.DataLink.Fields[0].Asstring+' '+DBGrid1.DataLink.Fields[1].Asstring; DBGrid1.DataLink.ActiveRecord := OldRec;end;end.
 
后退
顶部