下面这个假设行高和列宽都用默认值,如果你的行高和列宽改了,把计算方法换一下就行了(用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;
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;