タイピング量を減らす目的で、
StringGrid1.Cells[i,j] を短く S[i,j] という表現で参照することができますか?
そのとき配列 S をどのように宣言すればいいのですか?
できますよ。見かけ上は。
フォームのプロパティーにするとよいです。
type
TForm1 = class(TForm)
StringGrid1: TStringGrid;
Button1: TButton;
Label1: TLabel;
procedure Button1Click(Sender: TObject);
private
function GetCells(ACol, ARow: Integer): string;
procedure SetCells(ACol, ARow: Integer; const Value: string);
public
property S[ACol, ARow: Integer]: string read GetCells write SetCells;
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
function TForm1.GetCells(ACol, ARow: Integer): string;
begin
result := StringGrid1.Cells[ACol,ARow];
end;
procedure TForm1.SetCells(ACol, ARow: Integer; const Value: string);
begin
StringGrid1.Cells[ACol,ARow] := Value;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
S[3,3] := 'TEST';
Label1.Caption := S[3,3];
end;
迅速的確な御教示に、無限の感謝です!
jok様ありがとうございました。