掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
StringGridのFontや大きさを変更するには? (ID:42720)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
FireMonkeyではすべてのセルに TTextCell(TEdit) が割り当てられます。 この各TTextCellを格納する配列が、 TColumn で protected FCellControls: array of TStyledControl; として宣言されています。 要は、この FCellControls[] にアクセルできればよいわけですが、 方法が2つあります。 方法1 単純な StringGrid であれば、 StringGrid内 の 各StringColumn はそれぞれ、 Children[], ChildrenCount Components[], ComponentCount のプロパティを持っていますが、 この Children[], Components[] に FCellControls[] がセットされます。 (ChildrenCount, ComponentCount は、StringGrid.RowCount) 以下コードを記述。 type TForm1 = class(TForm) StringGrid1: TStringGrid; StringColumn1: TStringColumn; procedure FormCreate(Sender: TObject); private { private 宣言 } public { public 宣言 } end; procedure TForm1.FormCreate(Sender: TObject); {/////////////////////////////////////////////////////////////// FormCreate ///////////////////////////////////////////////////////////////} var I: Integer; begin inherited; with StringColumn1 do begin for I := 0 to ComponentCount-1 do if Components[I] is TTextCell then begin TTextCell(Components[I]).Font.Family := 'メイリオ'; TTextCell(Components[I]).Font.Size := 14; TTextCell(Components[I]).TextAlign := TTextAlign.taCenter; end; end; end; 方法2 TStringColumn を新たに定義して FCellControls を可視化する。 type TStringColumn = class(FMX.Grid.TStringColumn) function GetCellControl(Index: Integer): TTextCell; public property CellControls[Index: Integer]: TTextCell read GetCellControl; end; TForm1 = class(TForm) StringGrid1: TStringGrid; StringColumn1: TStringColumn; private { private 宣言 } public { public 宣言 } end; 以下、省略。(忙しいので、あとは自分でお考えください)
←解決時は質問者本人がここをチェックしてください。
更新する
戻る
掲示板システム
Copyright 2021 Takeshi Okamoto All Rights Reserved.