Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim numero, vertSpace As Integer numero = 10 vertSpace = 5 Dim etichetta As Label For n = 0 To numero etichetta = New Label With etichetta .BackColor = Color.White .BorderStyle = BorderStyle.FixedSingle .Left = 0 .Top = (etichetta.Height + vertSpace) * (n Mod numero) End With Me.Controls.Add(etichetta) Next End Sub End ClassE funziona alla grande!
Non ho ancora raccolto le etichette in una ArrayList, che permetterà di fare riferimento a ogni singolo elemento della matrice.
Ho anche creato l'arraylist, insieme con l'evento che mi permette di vedere se il riferimento all'elemento funziona.
Public Class Form1 Dim Etichette As ArrayList Private Sub Form1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Click Etichette(2).backcolor = Color.Yellow End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Etichette = New ArrayList Dim numero, vertSpace As Integer numero = 10 vertSpace = 2 Dim etichetta As Label For n = 0 To numero etichetta = New Label With etichetta .BackColor = Color.White .BorderStyle = BorderStyle.FixedSingle .Left = 0 .Top = (etichetta.Height + vertSpace) * (n Mod numero) End With Me.Controls.Add(etichetta) Etichette.Add(etichetta) Next End Sub End ClassE funziona!
Nessun commento:
Posta un commento