Quantcast
Channel: Visual Basic Tips and Tricks
Viewing all articles
Browse latest Browse all 2212

creare/eliminare un array di button

$
0
0

buonasera a tutti,

ho un problema che non riesco a risolvere, ho una serie di tasti sulla sinistra del mio form che rappresentano una categoria quando premo il primo mi crea X bottoni sulla destra apparatenenti alla relativa categoria tramite un array di button in questa maniera:

For j = 0 To tabella_tasti.Rows.Count - 1
            btnArray2(j) = New System.Windows.Forms.Button
            btnArray2(j).Size = New Size(122, 77)
            btnArray2(j).Text = tabella_tasti.Rows(j)("product")
            btnArray2(j).Margin = New Padding(6, 6, 6, 6)
            btnArray2(j).TextAlign = ContentAlignment.BottomCenter
            'AGGIUNGI TASTO PRODOTTI
            FlowLayout2.Controls.Add(btnArray2(j))
            'AGGIUNGI EVENTO CLICK TASTO
            AddHandler btnArray2(j).Click, AddressOf click_tasto
Next

il problema nasce nel momento in cui premo il secondo tasto "categoria" che mi aggiunge gli altri bottoni in coda al mio flowlayoutpanel. 

come faccio a rimuovere e svuotare l'array di bottoni affinchè venga rigenerato con i nuovi tasti?



Viewing all articles
Browse latest Browse all 2212