自作のプロパティを作成しているのですが、integer型の配列型のプロパティにしようとして、困っています。以下に現状のソースを置きますので、どなたかわかる方いましたらどこが悪いかご指摘いただければ、お願いします。
unit StringGridEx;
interface
uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Grids;
type
TAInt = array[0..255] of Integer;
type
TFrameStringGridEx = class(TFrame)
StringGrid1: TStringGrid;
procedure StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
private
FCenterCols: TAInt;
procedure SetCenterCols(const Value: TAInt);
{ Private 宣言 }
public
{ Public 宣言 }
property CenterCols:TAInt read FCenterCols write SetCenterCols;
end;
implementation
以下省略
配列のプロパティは、
property CenterCols[Index: integer] :integer read GetCenterCols write SetCenterCols;
function GetCenterCols(Index: integer): integer;
procedure SetCenterCols(Index: Integer; const Value: integer);
となります。
この場合、readやwriteに変数を設定するのでなく、ファンクション、プロシージャになります。
配列をいっぺんに設定・取得するプロパティを作るより、そういうメソッドを用意して、
Procedure Assign(intArray: TAInt);
などとしたほうがいいと思います。
にしのさんいつもありがとうございます。
ご指摘どおりにしたら、なんなく解決しました。
本当にありがとうございました。
ツイート | ![]() |