Closing SplitContainer's panel with a standard button


I have a SplitContainer with two panels.  I want to make one of them to be closed with a standard Windows closing button (X - Button).

Any comments will be helpful.


Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jorge PaulinoIT Pro/DeveloperCommented:
You can do:
Me.SplitContainer1.Panel1Collapsed = False

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
afikimAuthor Commented:
Hi JPaolino

I tried your code.  It doesn't do what I need.
I need the panel to be with "X" button for closing it.  Is there any standard closing button to do that?



Jorge PaulinoIT Pro/DeveloperCommented:
>> I need the panel to be with "X" button for closing it.  Is there any standard closing button to do that?
You can create your "X" button and use that code.
Maybe I'm not understand it right!
I think what jpaulino means is that you would have to put a Button on your form and put this in the button's click event:

SplitContainer1.Panel1Collapsed = True

This would close Panel1 of the Split Container (The left panel for a vertical splitter, or the top panel for a horizontal splitter).

If you want to re-open the panel, you use "SplitContainer1.Panel1Collapsed = False"

Best would be to code the button to toggle the collapse:

  SplitContainer1.Panel1Collapsed = Not SplitContainer1.Panel1Collapsed

This would collapse the panel if is isn't collapsed, and open it if it is collapsed.
afikimAuthor Commented:
Hi JPaulino and gisTimmy

First I thought that there might be a standard "close button to the panel but now I understand that there isn't such a button.

As for the code JPaulino wrote,  I was a little confused.  It should have beed "Me.SplitContainer1.Panel1Collapsed = True" .

Thanks you both and enjoy your day

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.