我在ColEnter事件中写:
procedure TForm1.DBGridEh1ColEnter(Sender: TObject);
begin
  ShowMessage('Row = ' + IntToStr(DBGridEh1.Row) + '   Col = ' + 
               IntToStr(DBGridEh1.Col)   + '    ' + 
          IntToStr(DBGridEh1.CellRect(DBGridEh1.Row,DBGridEh1.Col).Left));
end;不管用,那位检查一下,帮忙给个解决办法,谢谢!

解决方案 »

  1.   

    谢谢楼上的关注,
    我是想取该坐标,在该坐标下方弹出一个面板DBGridEh1.CellRect(DBGridEh1.Row,DBGridEh1.Col).Left得不到正确的单元格坐标,很多单元格都为Left = 0
      

  2.   

    Translates a given point from client area coordinates to global screen coordinates.function ClientToScreen(const Point: TPoint): TPoint;DescriptionUse ClientToScreen to convert a point whose coordinates are expressed locally to the control to the corresponding point in screen coordinates. In client area coordinates (0, 0) corresponds to the upper left corner of the control's client area. In screen coordinates (0, 0) corresponds to the upper left corner of the screen.Use ScreenToClient along with ClientToScreen to convert from one control's coordinate system to another control's coordinate system. For example, P := TargetControl.ScreenToClient(SourceControl.ClientToScreen(P));converts P from coordinates in SourceControl to coordinates in TargetControl.
      

  3.   

    StringGrid1.CellRect(StringGrid1.Col,StringGrid1.Row).Left
    StringGrid1.CellRect(StringGrid1.Col,StringGrid1.Row).Top这是用于StringGrid1的,也可以用于DBGridEh1,
    看看
    http://expert.csdn.net/Expert/topic/1986/1986064.xml?temp=.1791498
      

  4.   

    outer2000(天外流星):
    我照你的测了一下,代码如下:
    procedure TForm1.DBGridEh1ColEnter(Sender: TObject);
    var
      pLT: TPoint;
      pRB: TPoint;
      rRect: TRect;
    begin
      rRect := DBGridEh1.CellRect(DBGridEh1.row,DBGridEh1.col);
      
      pLT := DBGridEh1.ClientToScreen(Point(rRect.Left, rRect.Top));
      pRB := DBGridEh1.ClientToScreen(Point(rRect.Right, rRect.Bottom));  Panel1.Left := pLT.X;
      Panel1.Top := pRB.Y;
    end;Panel1的位置也不知道是按什么规律在动,到处瞎蹦
    拜托哪位测一下,我想让Panel1以单元格Left为左边届,贴着单元格下边显示tanqth(青蛙) :我的方法和你给出贴子中得分那位兄弟的一样
      

  5.   

    procedure TForm1.DBGridEh1ColEnter(Sender: TObject);
    var
      pLT: TPoint;
      pRB: TPoint;
      rRect: TRect;
    begin  
      rRect := DBGridEh1.CellRect(DBGridEh1.col, DBGridEh1.row); //反了  pLT := DBGridEh1.ClientToParent(rRect.TopLeft);     //用ClientToParent
      pRB := DBGridEh1.ClientToParent(rRect.BottomRight); //用法见帮助  Panel1.Left := pLT.X;
      Panel1.Top := pRB.Y;  Panel1.Caption := 'Left = ' + IntToStr(pLT.X) + '    Bottom = ' + IntToStr(pRB.Y);end;
      

  6.   

    procedure TForm1.DBGridEh1CellClick(Column: TColumnEh);
    begin
     showmessage(inttostr(dbgrideh1.Row));
     showmessage(inttostr(dbgrideh1.SelectedIndex));
    end;