Hello group
I have a strange problem. I have a panel. On this panel, I can drop custom
Textbox that I create at runtime. I have a toolbar on witch a delete button
exist. When I click on this button, the application delete the select
Textbox on the panel. I allso give the ability to the Texbox to contains
others Textbox. That mean that my fonction is recursiv.
This is the code when I clik on the delete button
'I check is I have something selected
If Not mobjItemDragDrop Is Nothing Then
'mobjItemDragDrop is the selected Textbox on my
Panel or in an other Texbox
mpDelete(mobjItemDragDrop, mobjItemDragDrop.Parent)
End If
Here is my fonction that I call when I delete something
Private Sub mpDelete(ByRef sender As Control, ByRef senderParent As Control)
Const METHODE As String = "mpDelete"
Dim objItem As clsCustomTB
Try
If sender.Controls.Count > 0 Then
For Each objItem In sender.Controls
If objItem.Controls.Count > 0 Then
mpDelete(objItem, objItem.Parent)
End If
sender.Controls.Remove(objItem)
sender.Refresh()
Next
senderParent.Controls.Remove(sender)
senderParent.Refresh()
Else
senderParent.Controls.Remove(sender)
senderParent.Refresh()
End If
Catch ex As Exception
mgAddErreur(ex,
System.Reflection.Assembly.GetExecutingAssembly.Lo cation, CLASSE, METHODE,
System.Windows.Forms.SystemInformation.ComputerNam e,
System.Windows.Forms.SystemInformation.UserName, True)
End Try
End Sub
The strange Thing is when I check the Count property it is equal to 0 but on
my panel or in my Textbox, I can still see the control that have been
remove. I want to know what I am doing wrong here? Why the count is equal
to 0 but the control still exist? Is there a better way to remove a control
from it parent's?
Thank you
Marc R.