请教高手,如何取得鼠标所在单元格的列数或行数?

解决方案 »

  1.   

    procedure TForm1.StringGrid1MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
    var
      Column, Row: Longint;
    begin
      StringGrid1.MouseToCell(X, Y, Column, Row);
      StringGrid1.Cells[Column, Row] := 'Col ' + IntToStr(Column) +
        ',Row ' + IntToStr(Row);end;
      

  2.   

    procedure TForm1.StringGrid1Mousemove(Sender: TObject;
     Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
    var
     GC: TGridCoord;
    begin
     GC := StringGrid1.MouseCoord(X, Y);
     // GC.X 即鼠标所选择的行中的列号。
     Caption := Format('%d %d', [GC.X, GC.Y]);
    end;
      

  3.   

    多谢sysu,bozto sysu:我真的开始佩服你了!:)能请教你的职业吗?
      

  4.   

    谢谢!再请教:你接触delphi多久了?:)很想知道要多久才能有你这样的水准。