掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
コンポーネント作成でStringGridのセルに付帯情報をもたせたい。 (ID:3180)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
できますよ、配列。 Get関数と、Setプロシージャを用意しましょう。直接代入は無理です。 FCellProperty: TStringList; function GetCellProperty(ACol, ARow: Integer): string; procedure SetCellProperty(ACol, ARow: Integer; const Value: string); property CellProperty[ACol, ARow: Integer]: string read GetCellProperty write SetCellProperty; function TStringGridEx.GetCellProperty(ACol, ARow: Integer): string; var Row: TStringList; begin while FCellProperty.Count < ARow + 1 do begin FCellProperty.Add(''); end; Row := TStringList.Create; Row.CommaText := FCellProperty.Strings[ARow]; while Row.Count < ACol + 1 do begin Row.Add(''); end; Result := Row.Strings[ACol]; Row.Free; end; procedure TStringGridEx.SetCellProperty(ACol, ARow: Integer; const Value: string); var Row: TStringList; begin while FCellProperty.Count < ARow + 1 do begin FCellProperty.Add(''); end; Row := TStringList.Create; Row.CommaText := FCellProperty.Strings[ARow]; while Row.Count < ACol + 1 do begin Row.Add(''); end; Row.Strings[ACol] := Value; FCellProperty.Strings[ARow] := Row.CommaText; Row.Free; end; こんな感じです。 FCellPropertyの初期化・解放を忘れずに。
←解決時は質問者本人がここをチェックしてください。
戻る
掲示板システム
Copyright 2021 Takeshi Okamoto All Rights Reserved.