お世話になっています
さて表題の件ですが実際に使用しているコンポーネントは TJvRichEdit と TEditor ですが
わかりやすく TMemo と TRichEdit で
private
PlainEditMode:Boolean;
function GetEditorSelLength:integer;
function TForm1.GetEditorSelLength: integer;
begin
if PlainEditMode then Result:=Memo1.SelLength else
Result:=RichEdit1.SelLength;
end;
これでモードによって SelLength を取得は出来るのですが代入が出来ません
GetEditorSelLength:=2;
等という風にしたいのですが何か方法はありますでしょうか?
私の開発環境は Delphi2009 ud4 です
D5 以降の新機能をあまり使いこなせていませんので何かそのあたりに手がありそうなのですが
以上、よろしくお願いいたしますm(_ _)m
それプロパティじゃなくて関数に代入してますよね…。
新機能以前の問題だと思うのですが…。
GetができるのにSetができない理由がわかりませんけど???
private
function GetEditorSelLength: Integer;
procedure SetEditorSelLength(SelLength: Integer);
public
property EditorSelLength: Integer read GetEditorSelLength write SetEditorSelLength;
function TForm1.GetEditorSelLength: integer;
begin
if PlainEditMode then Result:=Memo1.SelLength else
Result:=RichEdit1.SelLength;
end;
procedure TForm1.SetEditorSelLength(SelLength: Integer);
begin
if PlainEditMode then
Memo1.SelLength := SelLength
else
RichEdit1.SelLength := SelLength;
end;
使用例)
procedure TForm1.Button1Click(Sender: TObject)
begin
if EditorSelLength > 2 then EditorSelLength := 2;
end;
新機能どころか、おそらくDelphi2ぐらいからある方法です
あいかわらずメモ帳で入力したので不備があるかもしれませんが
private
PlainEditMode:Boolean;
function GetEditorSelLength:integer;
procedure SetEditorSelLength(const Value : Integer);
public
property EditorSelLength : Integer read GetEditorSelLength
write SetEditorSelLength;
function TForm1.GetEditorSelLength: integer;
begin
if PlainEditMode then Result:=Memo1.SelLength else
Result:=RichEdit1.SelLength;
end;
function TForm1.SetEditorSelLength(const Value : Integer): integer;
begin
if PlainEditMode then Memo1.SelLength := Value else
RichEdit1.SelLength := Value;
end;
取得する場合
Len := EditorSelLength;
代入する場合
EditorSelLength := 2;
あれ?すみません
プロパティを異なるコンポーネントで使い分けるということに思い至りませんでした
あたしってほんとバカ
ありがとうございました
ツイート | ![]() |