Hi everyone...!!...I ask sorry for my bad English
Here is my problem.......I have a MDI child with a Panel that have "AutoScroll = True".....and where i Add Buttons during runtime....First i had a Problem with the AutoScrollPosition Which i finally solve with the "System.Drawing.Point"...
I use "a New ArrayList"...Where the buttons appears (on each click) one beside another in horizontal position inside Panel1...
My Problem is when i try to Remove this controls (buttons) form the panel...
I try this code but nothing happens...
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
If Panel1.Controls.Contains(botHo) Then
Panel1.Controls.Remove(botHo)
End If
End Sub
this is my code...:
Private count1 As Integer = 2
Private arrayctl_1 As New ArrayList
Private Y As Integer = 20
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim nuevaHoja As New Button
nuevaHoja.Text = "Hoja" & " " & count1
count1 += 1
arrayctl_1.Add(nuevaHoja)
DrawControls()
End Sub
Private Sub DrawControls()
Dim botHo As Button
Dim CurrentPoint As System.Drawing.Point
CurrentPoint = Panel1.AutoScrollPosition()
Dim i As Integer = 0
Panel1.Controls.Clear()
Panel1.SuspendLayout()
For Each botHo In arrayctl_1
Panel1.Controls.Add(botHo)
botHo.Focus()
botHo.Height = Y
botHo.Left = i
i += botHo.Width
Next
Panel1.ResumeLayout()
Panel1.AutoScrollPosition = New Point(Math.Abs(Panel1.AutoScrollPosition.X), Math.Abs(CurrentPoint.Y))
End Sub
CAN ANYONE GIVE ME AN ADVISE PLEASE...!!!
Here is my problem.......I have a MDI child with a Panel that have "AutoScroll = True".....and where i Add Buttons during runtime....First i had a Problem with the AutoScrollPosition Which i finally solve with the "System.Drawing.Point"...
I use "a New ArrayList"...Where the buttons appears (on each click) one beside another in horizontal position inside Panel1...
My Problem is when i try to Remove this controls (buttons) form the panel...
I try this code but nothing happens...
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
If Panel1.Controls.Contains(botHo) Then
Panel1.Controls.Remove(botHo)
End If
End Sub
this is my code...:
Private count1 As Integer = 2
Private arrayctl_1 As New ArrayList
Private Y As Integer = 20
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim nuevaHoja As New Button
nuevaHoja.Text = "Hoja" & " " & count1
count1 += 1
arrayctl_1.Add(nuevaHoja)
DrawControls()
End Sub
Private Sub DrawControls()
Dim botHo As Button
Dim CurrentPoint As System.Drawing.Point
CurrentPoint = Panel1.AutoScrollPosition()
Dim i As Integer = 0
Panel1.Controls.Clear()
Panel1.SuspendLayout()
For Each botHo In arrayctl_1
Panel1.Controls.Add(botHo)
botHo.Focus()
botHo.Height = Y
botHo.Left = i
i += botHo.Width
Next
Panel1.ResumeLayout()
Panel1.AutoScrollPosition = New Point(Math.Abs(Panel1.AutoScrollPosition.X), Math.Abs(CurrentPoint.Y))
End Sub
CAN ANYONE GIVE ME AN ADVISE PLEASE...!!!