怎样实现,当用鼠标滑过Grid的时候,能够将Grid的行和列读出来呢,该用什么事件呢,该怎么判断是哪行呢

解决方案 »

  1.   

    是当前鼠标经过的行,列还是Grid的当前行和列?
      

  2.   

    下面这个假设行高和列宽都用默认值,如果你的行高和列宽改了,把计算方法换一下就行了(用RowHeights属性和ColWidths属性)procedure TForm1.StringGrid1MouseMove(Sender: TObject; Shift: TShiftState;
      X, Y: Integer);
    var
      r, c: integer;
    begin
      edit1.Text:= Inttostr(StringGrid1.Row)+','+Inttostr(Stringgrid1.Col);
      edit2.Text:= Inttostr(X)+','+Inttostr(Y);
      r:= Y div stringgrid1.DefaultRowHeight;
      c:= X div stringgrid1.DefaultColWidth;
      edit3.Text:= Inttostr(r)+','+Inttostr(c);
    end;