Skip to content

Instantly share code, notes, and snippets.

@freeonterminate
Created November 20, 2017 02:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save freeonterminate/d70b51e3fbd2704d0017de40297090fd to your computer and use it in GitHub Desktop.
Save freeonterminate/d70b51e3fbd2704d0017de40297090fd to your computer and use it in GitHub Desktop.
TText, TGridLayout の BeginUpdate / EndUpdate 利用
uses
System.Generics.Collections;
type
TOpenText = class(TText);
procedure TForm1.CreateRandomText;
var
x, y: Integer;
Text: TText;
Texts: TList<TText>;
begin
Texts := TList<TText>.Create;
try
GridLayout1.BeginUpdate;
try
for y := 0 to Trunc(GridLayout1.Height / GridLayout1.ItemHeight) do
for x := 0 to Trunc(GridLayout1.Width / GridLayout1.ItemWidth) do
begin
Text := TText.Create(Self);
Texts.Add(Text);
TOpenText(Text).Layout.BeginUpdate;
Text.Text := Chr(Ord('A') + Random(25));
GridLayout1.AddObject(Text);
end;
for Text in Texts do
TOpenText(Text).Layout.EndUpdate;
finally
GridLayout1.EndUpdate;
end;
finally
Texts.DisposeOf;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
CreateRandomText;
end;
procedure TForm1.FormResize(Sender: TObject);
begin
CreateRandomText;
end;
end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment