Created
November 20, 2017 02:33
-
-
Save freeonterminate/d70b51e3fbd2704d0017de40297090fd to your computer and use it in GitHub Desktop.
TText, TGridLayout の BeginUpdate / EndUpdate 利用
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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