[Gambas-user] how to destroy and array of ojects?
Bruce Steers
bsteers4 at gmail.com
Sat Dec 16 00:11:44 CET 2023
On Fri, 15 Dec 2023 at 22:28, <roberto.premoli at tiscali.it> wrote:
>
> hello, i have a panel, i create an array of button inside as follow.
>
> Private mbl_button As New Button[40]
>
> row = 4
> col = 10
> quantity = 39
>
> For b As Integer = 0 To quantity
> With mbl_button[b] = New Button(tastiera_panel) As "tastiera_array"
> mbl_button[b].x = (b % col) * (tastiera_pannello.Width / col)
> mbl_button[b].w = tastiera_panel.width / col
> mbl_button[b].h = tastiera_panel.Height / row
> mbl_button[b].y = Int(b / col) * mbl_button[b].h
> mbl_button[b].name = b
> mbl_button[b].Border = 1
> mbl_button[b].text = b
> End With
> Next
>
> it create a matrix 4x10 of buttons, it works ok.
>
> now my need: along the program, I need to recreate another matrix (let say 2x5), so is enough to
> chage parameters (row = 2, col = 5, quantity = 19) and recall the code. But if i do,
> i create new buttons over the existing buttons: what i need is fist destroy the existing 4x10 buttons and
> then create on same place my new matryx 2x5.
>
> i need something as
>
> For b As Integer = 0 To quantity
> destroy(mbl_button[b])
> Next
>
>
> how can I do it?
> thanks
>
Like the other Bruce says to clear all panel objects in one go use
tastiera_panel.Children.Clear
for an amout of buttons but not all you can use Control.Delete
For b As Integer = 0 To quantity
mbl_button[b].Delete
Next
BruceS
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20231215/9a4fc468/attachment.htm>
More information about the User
mailing list