Hello:
I created a form with a horizontal SplitContaner with 2 Panels.
Question:
1) Can I rename the panels? Seem that I cant and they are named Panel1 and Panel2.
2) When I maximize the form, I would like to have the top panel (Panel1) keep a depth of X amount. I cant find where I can set the size/depth of it. The other panel (Panel2) I would like it to size to the maximun of what is left.
Loading
Sam HobbsPosted Apr 7, 2010, 3:13 PM
SplitterPanel UpperPanel;
SplitterPanel LowerPanel;
Or something such as that. Then in the form constructor:
UpperPanel = splitContainer1.Panel1;
LowerPanel = splitContainer1.Panel2;
Use whatever names you want.
To make the upper panel fixed in height, in the form constructor save the SplitterDistance:
SplitterDistance = splitContainer1.SplitterDistance;
Of course SplitterDistance is an int in the form's class. Then add a handler for the SplitContainer's SizeChanged event and set the splitContainer1.SplitterDistance back to the original value. You might need to change the Locked and/or IsSplitterFixed properties in the SplitContainer to true.
I knew very little about SplitContainers but I figured out the above myself.
Sam HobbsPosted Apr 7, 2010, 6:27 PM
GustavoPosted Apr 7, 2010, 5:37 PM
Thanks... Will try to implement it now. It sounds like it will work.
BTW: I did some of what you said, but it still did not fix or set the height of the top pane, correctly. I will just have to play with it.
GustavoPosted Apr 7, 2010, 12:55 PM
Thanks, I will do that for now.
I really wanted the top panel to be a fixed height/width...
Hirendra SisodiyaPosted Apr 7, 2010, 8:16 AM
hello Giorgio
Answeres of your question:
1) Can I rename the panels? Seem that I cant and they are named Panel1 and Panel2.
Ans: No
2) When I maximize the form, I would like to have the top panel (Panel1) keep a depth of X amount. I cant find where I can set the size/depth of it. The other panel (Panel2) I would like it to size to the maximun of what is left.
Ans: you can do it with the help of SplitterDistance property,suppose that if you want to set the size of panel1 to 2/3rd of form size, you can use this code sample:
private void Form2_Resize(object sender, EventArgs e)
{
splitContainer1.SplitterDistance =splitContainer1.Width * 2 / 3;
}
thanks
Please mark as answere if it helps