Private Sub LoadComponentCalendar()
For iter As Integer = 0 To listdaypicture.Length - 1
listdaypicture(iter) = New
listdaypicture(iter).Tag = iter
AddHandler listdaypicture(iter).Paint, AddressOf listdaypicture_paint
Next
end sub
je voudrai écrire dans chaque picturebox
son tag
Private Sub listdaypicture_paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs)
'
End Sub
Il serait beaucoup plus simple de définir votre propre picture box avec affichage du tag par héritage.
Par exemple
Public Class CalendarPictureBox
Inherits PictureBox
'Font pour l'affichage du tag
Private tagFont As New Font("Arial", 8)
Protected Overrides Sub OnPaint(ByVal pe As System.Windows.Forms.PaintEventArgs)
MyBase.OnPaint(pe)
'S'il y a un tag à dessiner
If (Me.Tag IsNot Nothing) Then
'Dessine le tag en haut à gauche de la picturebox
pe.Graphics.DrawString(Me.Tag.ToString(), tagFont, Brushes.Black, New PointF(3.0, 3.0))
End If
End Sub
End Class
De cette manière vous n'avez qu'a faire
Private listdaypicture(34) As CalandarPictureBox
Private Sub LoadComponentCalendar()
For iter As Integer = 0 To listdaypicture.Length - 1
listdaypicture(iter) = New
listdaypicture(iter).Tag = iter
Next
end sub
Et le tour est joué. Votre CalendarPictureBox s'utilise comme un PictureBox sauf qu'il affiche son tag.