Click here to Skip to main content
15,891,423 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, I had a problem here.

I created object at runtime (such as panel and button) and I need to remove it at RUNTIME too.
How could I do that?

This is the code that i'd tried :

VB
'Here's the code I use to create the object

Dim panelMenu As New SplitContainer
Dim leftP As New ucLeftMenu

.
.
.
.
'and these the code that i'd tried to remove those objects


            With Me.Controls
                .Remove(leftP)
                .Remove(panelMenu)
            End With




But the result is not as expected.
The panelMenu still exist and visible.

How to fix it?

Thanks in advance

[edit]"Treat my content as plain text..." option disabled - OriginalGriff[/edit]
Posted
Updated 19-Feb-12 0:01am
v3

1 solution

Your design doesn't make any sense. Why would you want to remove the splitter?? If it was a requirement, I would have a second form the doesn't have the splitter instead of going through the expense of removing controls from the splitter panels and having to tear out all the events handlers manually. It gets worse if you want to put all this stuff back.
 
Share this answer
 
Comments
satrio_budidharmawan 19-Feb-12 14:46pm    
what I try to do is this :
- firstly,I have a form that contain ONLY tabcontrol1
- I click button [Show Left Panel] to show left menu which has property ( .parent=panelmenu.panel1 ).
- and then I place tabcontrol1 to panelmenu.panel2 ( .parent=panelmenu.panel2 )

so, that I got form that has left( consist left panel) and right( consist tabcontrol1) side.

But when I press [Hide Left Panel] Button, the form transform back to the beginning which ONLY consist tabcontrol1.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900