Ecco la funzione flessibile:
Private Sub creaColonna(mese As Integer, anno As Integer,
labelWidth As Integer, labelHeight As Integer,
horSpace As Integer, vertSpace As Integer,
isCalendar As Boolean)
Dim giorniDelMese As Integer = DaysInMonth(anno, mese)
Dim perColumn = giorniDelMese
Dim giorno As New Date(anno, mese, 1)
For n = 0 To giorniDelMese - 1
mLabel = New Label
If isCalendar Then mLabel.Text = giorno.ToString("dddd" + " " + "dd/MMMM/yyyy").ToUpper
giorno = giorno.AddDays(1)
mLabel.Width = labelWidth
mLabel.Height = labelHeight
mLabel.BorderStyle = BorderStyle.FixedSingle
mLabel.AutoSize = False
mLabel.Left = (mLabel.Width + horSpace) * (n \ perColumn)
mLabel.Top = (mLabel.Height + vertSpace) * (n Mod perColumn)
Controls.Add(mLabel)
Next
End Sub
Parametri:
- mese
- anno
- larghezza della label
- altezza della label
- spaziatura orizzontale
- spaziatura verticale
- variabile booleana che stabilisce se la colonna sia un calendario, con scritte le date, o no.
mentre se è impostata a False ottengo:
Funziona, anche se è ancora perfettibile...


Nessun commento:
Posta un commento