Me.Controls.Remove(MyRectangle) Me.Refresh()
Hidecache un contrôle mais ne le supprime pas
L'expressionde type 'System.windows.Forms.control' ne peut jamais être de type 'Microsoft.VisualBasic.PowerPacks.RectangleShape'.comprends tu qu'un Rectangle de dérive pas de Control?
Imports Microsoft.VisualBasic.PowerPacks Public Class Form1 Dim Canvas As New ShapeContainer Dim Rect1 As New RectangleShape Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Canvas.Parent = Me Rect1.Parent = Canvas Rect1.Size = New System.Drawing.Size(140, 140) Rect1.Location = New System.Drawing.Point(200, 200) Rect1.BackStyle = BackStyle.Opaque Rect1.BackColor = Color.White End Sub Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click Canvas.Shapes.Clear() ' supprime tous les rectangles dans le Canvas End Sub End Class
Je fini par avoir un rectangle sur chaque calendrier des mois différent.
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionFor Each cal as Calendrier in MyCalendar
For Each c As Control In Me.Controls If TypeOf c Is Label Then Else For Each RS As RectangleShape In mySC.Shapes Me.Controls.Remove(mySC) Next End If Next mySC = New ShapeContainer myRS = New RectangleShape mySC.Parent = Me myRS.Parent = mySC myRS.BorderColor = System.Drawing.Color.Red myRS.BorderWidth = 1 myRS.Location = New System.Drawing.Point(24, RecupPostionLabel1(objLabel)) myRS.Size = New System.Drawing.Size(127, 20)
Private MyCalendar As New List(Of Calendrier) Sub Charger_MyCalendar() Dim Mon_Calendrier As New Calendrier Me.FlowLayoutPanel1.Controls.Add(Mon_Calendrier) Mon_Calendrier.Label_Mois.Text = DateCours.ToString("Y") End Sub
Private _mySC As ShapeContainer Public Property mySC As ShapeContainer Get Return _mySC End Get Set(value As ShapeContainer) _mySC = value End Set End Property Public _myRS As RectangleShape Public Property myRS As RectangleShape Get Return _myRS End Get Set(value As RectangleShape) _myRS = value End Set End Property Public Sub AfficheRectangle(ByVal Objet_Label As Label) mySC = New ShapeContainer myRS = New RectangleShape mySC.Parent = Me myRS.Parent = mySC myRS.BorderColor = System.Drawing.Color.Red myRS.BorderWidth = 1 myRS.Location = New System.Drawing.Point(24, RecupPostionLabel1(Objet_Label)) myRS.Size = New System.Drawing.Size(127, 20) End Sub
For Each cal As Calendrier In MyCalendar Try cal.mySC.Shapes.Clear() Catch ex As Exception End Try Next