Is there a way you can create as many buttons as your while loop runs? For example, a while loop runs 5 times and creates 5 buttons. But another time, the while loop runs 9 times and then it will create 9 buttons. An array wouldn't work as it is limited.
I would still use an array but have for example arrButtons : array[1..100] of TButton ; Then have a global integer called iButtonMax which is the number of buttons you want. You can change that variable but all your code will be using for loops like for i := 1 to iButtonMax do begin arrButtons[ i ] := TButton.V=Create... etc
Setting value of Tag when you create each button, and then using its tButton.Tag will most easily ,
isum := isum + (Sender as TButton).Tag
best chnnel on youtube... thank you so much
How would i reset a form after the created components are no longer necessary
Is there a way you can create as many buttons as your while loop runs?
For example, a while loop runs 5 times and creates 5 buttons.
But another time, the while loop runs 9 times and then it will create 9 buttons.
An array wouldn't work as it is limited.
I would still use an array but have for example
arrButtons : array[1..100] of TButton ;
Then have a global integer called iButtonMax which is the number of buttons you want. You can change that variable but all your code will be using for loops like
for i := 1 to iButtonMax do
begin
arrButtons[ i ] := TButton.V=Create... etc
Hi, what do you do if you use images instead of buttons, how do you extract the data from a TImage as it has no caption?
You can use the Tag to identify the picture.
TButton(Sender).X is better than doing (Sender as TButton).X
You already know the type in your global array declaration.
Well and clean explained!
anyone know to create dynamic components across forms?
Thank very much indeed, good job..
top:= 20+i*(height+5) very simple
i love your videos
Thanks!
Thanks
juul
iSum:=iSum+1.......Inc(iSum) better, isn't it ?