I want to hide panel2 on a split container and have panel1 utilize the space. I was hoping setting Panel2Collapsed would do the trick, but no luck. Ideas?
A:
Setting Panel2Collapsed
property to true
in the form designer and programatically both work as you want them to (i.e. Panel1 then occupies all of the space)... so there must be something else going on.
Daniel LeCheminant
2009-03-14 06:30:08
+8
A:
This worked for me on a similar situation:
splitContainer1.Panel2Collapsed = true;
splitContainer1.Panel2.Hide();
I wanted the second panel to not be visible at all in some cases, so I implemented it this way.
Nikos Steiakakis
2009-03-14 06:43:38
If you don't set the SplitterDistance and calling Hide(), which part of Panel2 is visible?
Daniel LeCheminant
2009-03-14 06:48:49
If I recall correctly, if you didn't set the SplitterDistance, then at the far end of Panel1 the mouse cursor would change, making it evident that there is another panel there.
Nikos Steiakakis
2009-03-14 06:52:57
but what happens when the user resizes the form
CrashCodes
2009-03-14 07:00:47
@Nikos: Hmm... I can't recreate that :-/ That kind of issue exists with the `Splitter` control, but I thought the whole purpose of the SplitContainer was to do away with those issues...
Daniel LeCheminant
2009-03-14 07:01:30
@CrashCodes: If the splitcontainer is docked, or properly anchored it will resize with the form, and Panel1 will stay docked to fill the entire splitcontainer.
Nikos Steiakakis
2009-03-14 07:10:00
Okay. Tried it works great. I started removing lines to see which one did the trick; and I'm back down to splitContainer1.Panel2Collapsed = true; Fun stuff.
CrashCodes
2009-03-14 07:11:35
@CrashCodes: Meaning that just setting Panel2Collapsed works?
Daniel LeCheminant
2009-03-14 07:12:32
@Daniel L: You're right, it doesn't do that! I checked it out and most probably setting the SplitterDistance equal to the total width is most probably just redundant.
Nikos Steiakakis
2009-03-14 07:17:29
Yeah. Does now. Hot stuff.
CrashCodes
2009-03-14 07:17:31
Thanks guys, at least I know that I'm not crazy! Glad you got it to work :]
Daniel LeCheminant
2009-03-14 07:20:11
@Nikos: I think the .Hide() is redundant as well...
Daniel LeCheminant
2009-03-14 07:21:09