序号    姓名   年龄
1      小明    20
2      小东    30
3      小红    28
4      小放    34
5      小华    42
...    ...     ...想实现的功能为:就是当鼠标移动到小东这个字段中,那么就把"年龄"字段中的"30"显示在Hint中注:鼠标是移动不是点击...

解决方案 »

  1.   

    找到一个是lzy6204(为了忘却的记忆) 的:var
      Form1: TForm1;
      i,j:integer;implementation{$R *.DFM}type TMyGrid=Class(TCustomDBGrid);procedure TForm1.DBGrid1MouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    var
        B:TBook;
    begin
      DBGrid1.DataSource.DataSet.DisableControls;
      b:=DBGrid1.DataSource.DataSet.GetBook;
      i:=DBGrid1.MouseCoord(x,y).x;
      j:=DBGrid1.MouseCoord(x,y).y;
      TMyGrid(DBGrid1).DataSource.DataSet.MoveBy(j-TMyGrid(DBGrid1).DataLink.ActiveRecord-1);
      DBGrid1.Hint:=TMyGrid(DBGrid1).getfieldvalue(i-1);
      DBGrid1.DataSource.DataSet.GotoBook(b);
      DBGrid1.DataSource.DataSet.FreeBook(b);
      DBGrid1.DataSource.DataSet.EnableControls;
    end;procedure TForm1.ApplicationEvents1ShowHint(var HintStr: String;
      var CanShow: Boolean; var HintInfo: THintInfo);
    var RectWidth:integer;
    begin
      if HintInfo.HintControl.Name='DBGrid1' then begin
        with HintInfo do begin
          HintPos:=DBGrid1.ClientToScreen(TMyGrid(DBGrid1).CellRect(I,J).TopLeft);
          HideTimeout:=100;
          ReshowTimeout:=100;
        end;
        RectWidth:=TMyGrid(DBGrid1).CellRect(I,J).Right-TMyGrid(DBGrid1).CellRect(I,J).Left;
        Application.HideHint;
        CanShow:=DBGrid1.Canvas.TextWidth(DBGrid1.Hint)>RectWidth;
      end;
    end;end.
    --------------------------
    另外infopower2000的wwdbgrid支持这个功能楼主试试看,行不行?...
      

  2.   

    TO:gxgyj(杰克.逊)
        好滴,我试试,谢谢你~~哦!! 
       你进http://community.csdn.net/Expert/topic/3580/3580645.xml?temp=.7449304这个贴,
    我赠给你100分~~~另外:还有100分,征集更多的方法~~~
      

  3.   

    下面是infopower下载的地方。
    http://www.delphibox.com/search.asp?KeyWord=infopower&Submit=%BF%EC%CB%D9%CB%D1%CB%F7上面我转贴的代码,如果OK的话。请楼主回复一下!!!!
      

  4.   

    TO:gxgyj(杰克.逊)   你进http://community.csdn.net/Expert/topic/3580/3580645.xml?temp=.7449304这个贴,我赠给你100分~~~
      

  5.   

    procedure TForm1.DBGrid1MouseMove(Sender: TObject;
      Shift: TShiftState; X, Y: Integer);
    var
      Cell: TGridCoord;
    begin
      inherited;
      Cell:=DBGrid1.MouseCoord(X,Y);
      if (Cell.Y>0) then         //Cell.Y=0表示移动到标题上了,不对
      begin
        DBGrid1.Hint:=format('年龄为:%g',[ADOQueryOrder0.FieldbyName('年龄').AsFloat]);
        DBGrid1.ShowHint:=True;
      end  else
      begin
        DBGridEh3.Hint:='';
        DBGridEh3.ShowHint:=False;
      end;
    end;