By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,241 Members | 1,979 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,241 IT Pros & Developers. It's quick & easy.

Splitters and Docking

P: n/a
Has anyone really gotten the Docking and Splitter Bars to work for anyting
but the simplest application for two controls and one splitter bar filling
the whole form? If so, can you enlighten my on HOW! I even tried creating
background panels and docking them with the controls on the panels but the
docking order seems to be random! Another useless control from Microsoft I
think!
--
Dennis in Houston
Nov 21 '05 #1
Share this Question
Share on Google+
25 Replies


P: n/a
"Dennis" <De****@discussions.microsoft.com> schrieb:
Has anyone really gotten the Docking and Splitter Bars to work for anyting
but the simplest application for two controls and one splitter bar filling
the whole form? If so, can you enlighten my on HOW! I even tried
creating
background panels and docking them with the controls on the panels but the
docking order seems to be random!


Use the "Bring to foreground" and "Send into background" context menu items
of the controls in the Windows Forms designer to control the docking order.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #2

P: n/a
"Dennis" <De****@discussions.microsoft.com> schrieb:
Has anyone really gotten the Docking and Splitter Bars to work for anyting
but the simplest application for two controls and one splitter bar filling
the whole form? If so, can you enlighten my on HOW! I even tried
creating
background panels and docking them with the controls on the panels but the
docking order seems to be random!


Use the "Bring to foreground" and "Send into background" context menu items
of the controls in the Windows Forms designer to control the docking order.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #3

P: n/a
Dennis,

The splitter works fine when you know how, just some trying.

Your problem with the docking has nothing to do with the splitter, however
with the designer. When you use that it adds it in the way you drags it on
the form (Zorder).

It is easy to change in the designer generated code. Not efficient however
not really very expensive for performanse in my opinion is as well removing
those controls and adding them once in the load event (When you do it using
the designer you can do it everytime again when you change something)

What I find also very usefull to do is hidding and showing them. I have
forms where I have panels over panels as well splitting horizontal as
vertical. For that is however as well that Z order needed. (Z order is from
bottom to top.)

I hope this helps?

Cor
Nov 21 '05 #4

P: n/a
Dennis,

The splitter works fine when you know how, just some trying.

Your problem with the docking has nothing to do with the splitter, however
with the designer. When you use that it adds it in the way you drags it on
the form (Zorder).

It is easy to change in the designer generated code. Not efficient however
not really very expensive for performanse in my opinion is as well removing
those controls and adding them once in the load event (When you do it using
the designer you can do it everytime again when you change something)

What I find also very usefull to do is hidding and showing them. I have
forms where I have panels over panels as well splitting horizontal as
vertical. For that is however as well that Z order needed. (Z order is from
bottom to top.)

I hope this helps?

Cor
Nov 21 '05 #5

P: n/a

splitter control allows the user to resize THE DOCKED CONTROL that is
IMMEDIATELY BEFORE IT.
Therefore, to enable the user to resize a docked control at run
time:
1. Dock the control to be resized to an edge of a container.
2. Dock a splitter control to the same side of that container.

e.g: 1 splitter.
control1.Dock = DockStyle.Left
splitter1.Dock = DockStyle.Left
splitter1.MinExtra = 100
' Set the minimum size control2 can be sized to.
splitter1.MinSize = 75
' Set the minimum size control1 can be sized to.
control2.Dock = DockStyle.Fill
' Set control2 to fill the remaining space on the form.
Me.Controls.AddRange(New Control() {control2, splitter1,
control1}) ' Add in reverse order to ensure proper location.

e.g: 2 Splitters.
control1.Dock = System.Windows.Forms.DockStyle.Left
control1.Width = Me.ClientSize.Width \ 3
control2.Dock = System.Windows.Forms.DockStyle.Top
control2.Height = Me.ClientSize.Height * 2 \ 3
control3.Dock = System.Windows.Forms.DockStyle.Fill

splitter1.Location = New System.Drawing.Point(121, 0)
splitter1.Width = 3
splitter2.Dock = System.Windows.Forms.DockStyle.Top
splitter2.Height = 3

panel1.Controls.AddRange(New System.Windows.Forms.Control()
{control3, splitter2, control2}) ' Add in reverse order to ensure proper
location
panel1.Dock = System.Windows.Forms.DockStyle.Fill

Me.Controls.AddRange(New System.Windows.Forms.Control() {panel1,
splitter1, control1}) ' Add in reverse order to ensure proper location

Good Luck.
Atara

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 21 '05 #6

P: n/a

splitter control allows the user to resize THE DOCKED CONTROL that is
IMMEDIATELY BEFORE IT.
Therefore, to enable the user to resize a docked control at run
time:
1. Dock the control to be resized to an edge of a container.
2. Dock a splitter control to the same side of that container.

e.g: 1 splitter.
control1.Dock = DockStyle.Left
splitter1.Dock = DockStyle.Left
splitter1.MinExtra = 100
' Set the minimum size control2 can be sized to.
splitter1.MinSize = 75
' Set the minimum size control1 can be sized to.
control2.Dock = DockStyle.Fill
' Set control2 to fill the remaining space on the form.
Me.Controls.AddRange(New Control() {control2, splitter1,
control1}) ' Add in reverse order to ensure proper location.

e.g: 2 Splitters.
control1.Dock = System.Windows.Forms.DockStyle.Left
control1.Width = Me.ClientSize.Width \ 3
control2.Dock = System.Windows.Forms.DockStyle.Top
control2.Height = Me.ClientSize.Height * 2 \ 3
control3.Dock = System.Windows.Forms.DockStyle.Fill

splitter1.Location = New System.Drawing.Point(121, 0)
splitter1.Width = 3
splitter2.Dock = System.Windows.Forms.DockStyle.Top
splitter2.Height = 3

panel1.Controls.AddRange(New System.Windows.Forms.Control()
{control3, splitter2, control2}) ' Add in reverse order to ensure proper
location
panel1.Dock = System.Windows.Forms.DockStyle.Fill

Me.Controls.AddRange(New System.Windows.Forms.Control() {panel1,
splitter1, control1}) ' Add in reverse order to ensure proper location

Good Luck.
Atara

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 21 '05 #7

P: n/a
Thank you for your replies. I didn't know that that the Zorder affected the
way the controls were docked. It's still difficult to get the controls and
splitters where you want them.

"Dennis" wrote:
Has anyone really gotten the Docking and Splitter Bars to work for anyting
but the simplest application for two controls and one splitter bar filling
the whole form? If so, can you enlighten my on HOW! I even tried creating
background panels and docking them with the controls on the panels but the
docking order seems to be random! Another useless control from Microsoft I
think!
--
Dennis in Houston

Nov 21 '05 #8

P: n/a
Thank you for your replies. I didn't know that that the Zorder affected the
way the controls were docked. It's still difficult to get the controls and
splitters where you want them.

"Dennis" wrote:
Has anyone really gotten the Docking and Splitter Bars to work for anyting
but the simplest application for two controls and one splitter bar filling
the whole form? If so, can you enlighten my on HOW! I even tried creating
background panels and docking them with the controls on the panels but the
docking order seems to be random! Another useless control from Microsoft I
think!
--
Dennis in Houston

Nov 21 '05 #9

P: n/a
Ok, I got the splitter to working and the panels where I want them. However,
when I add two controls and a splitter between them to a panel as chldren of
the panel, they show up ok but I can't resize the widths of the controls
using the splitter between them. It works fine if the two controls and
splitter are directly on a form but when they are children of a panel, it
doesn't work.

"Cor Ligthert" wrote:
Dennis,

The splitter works fine when you know how, just some trying.

Your problem with the docking has nothing to do with the splitter, however
with the designer. When you use that it adds it in the way you drags it on
the form (Zorder).

It is easy to change in the designer generated code. Not efficient however
not really very expensive for performanse in my opinion is as well removing
those controls and adding them once in the load event (When you do it using
the designer you can do it everytime again when you change something)

What I find also very usefull to do is hidding and showing them. I have
forms where I have panels over panels as well splitting horizontal as
vertical. For that is however as well that Z order needed. (Z order is from
bottom to top.)

I hope this helps?

Cor

Nov 21 '05 #10

P: n/a
Ok, I got the splitter to working and the panels where I want them. However,
when I add two controls and a splitter between them to a panel as chldren of
the panel, they show up ok but I can't resize the widths of the controls
using the splitter between them. It works fine if the two controls and
splitter are directly on a form but when they are children of a panel, it
doesn't work.

"Cor Ligthert" wrote:
Dennis,

The splitter works fine when you know how, just some trying.

Your problem with the docking has nothing to do with the splitter, however
with the designer. When you use that it adds it in the way you drags it on
the form (Zorder).

It is easy to change in the designer generated code. Not efficient however
not really very expensive for performanse in my opinion is as well removing
those controls and adding them once in the load event (When you do it using
the designer you can do it everytime again when you change something)

What I find also very usefull to do is hidding and showing them. I have
forms where I have panels over panels as well splitting horizontal as
vertical. For that is however as well that Z order needed. (Z order is from
bottom to top.)

I hope this helps?

Cor

Nov 21 '05 #11

P: n/a
"Dennis" <De****@discussions.microsoft.com> schrieb:
Ok, I got the splitter to working and the panels where I want them.
However,
when I add two controls and a splitter between them to a panel as chldren
of
the panel, they show up ok but I can't resize the widths of the controls
using the splitter between them. It works fine if the two controls and
splitter are directly on a form but when they are children of a panel, it
doesn't work.


You'll have to select the control above the splitter for horizontal
splitters or the control left to the splitter for vertical splitters and
change its size. This will move the splitter and resize the control docked
on the other side of the splitter.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #12

P: n/a
"Dennis" <De****@discussions.microsoft.com> schrieb:
Ok, I got the splitter to working and the panels where I want them.
However,
when I add two controls and a splitter between them to a panel as chldren
of
the panel, they show up ok but I can't resize the widths of the controls
using the splitter between them. It works fine if the two controls and
splitter are directly on a form but when they are children of a panel, it
doesn't work.


You'll have to select the control above the splitter for horizontal
splitters or the control left to the splitter for vertical splitters and
change its size. This will move the splitter and resize the control docked
on the other side of the splitter.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #13

P: n/a
That works in designmode but does not allow resizing in run mode.

"Herfried K. Wagner [MVP]" wrote:
"Dennis" <De****@discussions.microsoft.com> schrieb:
Ok, I got the splitter to working and the panels where I want them.
However,
when I add two controls and a splitter between them to a panel as chldren
of
the panel, they show up ok but I can't resize the widths of the controls
using the splitter between them. It works fine if the two controls and
splitter are directly on a form but when they are children of a panel, it
doesn't work.


You'll have to select the control above the splitter for horizontal
splitters or the control left to the splitter for vertical splitters and
change its size. This will move the splitter and resize the control docked
on the other side of the splitter.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #14

P: n/a
That works in designmode but does not allow resizing in run mode.

"Herfried K. Wagner [MVP]" wrote:
"Dennis" <De****@discussions.microsoft.com> schrieb:
Ok, I got the splitter to working and the panels where I want them.
However,
when I add two controls and a splitter between them to a panel as chldren
of
the panel, they show up ok but I can't resize the widths of the controls
using the splitter between them. It works fine if the two controls and
splitter are directly on a form but when they are children of a panel, it
doesn't work.


You'll have to select the control above the splitter for horizontal
splitters or the control left to the splitter for vertical splitters and
change its size. This will move the splitter and resize the control docked
on the other side of the splitter.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #15

P: n/a
"Dennis" <De****@discussions.microsoft.com> schrieb:
That works in designmode but does not allow resizing in run mode.


Mhm... I am not able to repro that using VB.NET 2002.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #16

P: n/a
"Dennis" <De****@discussions.microsoft.com> schrieb:
That works in designmode but does not allow resizing in run mode.


Mhm... I am not able to repro that using VB.NET 2002.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #17

P: n/a
I'm using vb2003. I have a panel with child controls that has a listview
docked to the left, a Splitter docked left and another listview docked with
Fill. In run move, when I put the mouse on the splitter, I don't get
anything and can't resize the widths of the controls with the mouse. I works
ok in Design mode.

"Herfried K. Wagner [MVP]" wrote:
"Dennis" <De****@discussions.microsoft.com> schrieb:
That works in designmode but does not allow resizing in run mode.


Mhm... I am not able to repro that using VB.NET 2002.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #18

P: n/a
I'm using vb2003. I have a panel with child controls that has a listview
docked to the left, a Splitter docked left and another listview docked with
Fill. In run move, when I put the mouse on the splitter, I don't get
anything and can't resize the widths of the controls with the mouse. I works
ok in Design mode.

"Herfried K. Wagner [MVP]" wrote:
"Dennis" <De****@discussions.microsoft.com> schrieb:
That works in designmode but does not allow resizing in run mode.


Mhm... I am not able to repro that using VB.NET 2002.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #19

P: n/a
"Dennis" <De****@discussions.microsoft.com> schrieb:
I'm using vb2003. I have a panel with child controls that has a listview
docked to the left, a Splitter docked left and another listview docked
with
Fill. In run move, when I put the mouse on the splitter, I don't get
anything and can't resize the widths of the controls with the mouse. I
works
ok in Design mode.


I have tried the scenario you described in VS.NET 2002 (I currently don't
have VS.NET 2003 installed) and everything worked just fine.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #20

P: n/a
"Dennis" <De****@discussions.microsoft.com> schrieb:
I'm using vb2003. I have a panel with child controls that has a listview
docked to the left, a Splitter docked left and another listview docked
with
Fill. In run move, when I put the mouse on the splitter, I don't get
anything and can't resize the widths of the controls with the mouse. I
works
ok in Design mode.


I have tried the scenario you described in VS.NET 2002 (I currently don't
have VS.NET 2003 installed) and everything worked just fine.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #21

P: n/a
Herfried, I got it to work. You're not going to believe this but the problem
was that I had the vertical splitter sized to only 1 pixel and I wasn't
getting the mouse over it to resize the two controls on either side of it. I
changed to splitter size to 4 pixels wide and it works fine...what a dumb
mistake! Sorry for causing you to spend time on this kind of thing but
thanks anyway as your notes gave me confidence to keep working at it for the
solution.

"Herfried K. Wagner [MVP]" wrote:
"Dennis" <De****@discussions.microsoft.com> schrieb:
I'm using vb2003. I have a panel with child controls that has a listview
docked to the left, a Splitter docked left and another listview docked
with
Fill. In run move, when I put the mouse on the splitter, I don't get
anything and can't resize the widths of the controls with the mouse. I
works
ok in Design mode.


I have tried the scenario you described in VS.NET 2002 (I currently don't
have VS.NET 2003 installed) and everything worked just fine.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #22

P: n/a
Herfried, I got it to work. You're not going to believe this but the problem
was that I had the vertical splitter sized to only 1 pixel and I wasn't
getting the mouse over it to resize the two controls on either side of it. I
changed to splitter size to 4 pixels wide and it works fine...what a dumb
mistake! Sorry for causing you to spend time on this kind of thing but
thanks anyway as your notes gave me confidence to keep working at it for the
solution.

"Herfried K. Wagner [MVP]" wrote:
"Dennis" <De****@discussions.microsoft.com> schrieb:
I'm using vb2003. I have a panel with child controls that has a listview
docked to the left, a Splitter docked left and another listview docked
with
Fill. In run move, when I put the mouse on the splitter, I don't get
anything and can't resize the widths of the controls with the mouse. I
works
ok in Design mode.


I have tried the scenario you described in VS.NET 2002 (I currently don't
have VS.NET 2003 installed) and everything worked just fine.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #23

P: n/a
Dennis,

I believe this, because I had all those same problems as you the first time
with the splitter.

:-)

Cor
Nov 21 '05 #24

P: n/a
Dennis wrote:
Has anyone really gotten the Docking and Splitter Bars to work for anyting
but the simplest application for two controls and one splitter bar filling
the whole form? If so, can you enlighten my on HOW! I even tried creating
background panels and docking them with the controls on the panels but the
docking order seems to be random! Another useless control from Microsoft I
think!


The way it works for me is thinking ahead and then adding the controls
in the right order. So if I want 2 panels with a vertical splitter I add
1 panel, then the splitter, then the next panel. This seems to work for me.

--
Rinze van Huizen
C-Services Holland b.v.
Nov 21 '05 #25

P: n/a
Here is a generic algorithm I wrote to add multiple items to a panel with
splitters between them. This should handle between 1..N controls.

Control main = null;
Control p = null;
Spliter sp = null;
ArrayList list = new ArrayList();

....
add controls to list that you want to have splitters between
....

// loop through the list of controls that we want to add to the panel
// with a horizontal splitter between each one.
// We will loop through the list backwards to get the items to start
// at the top with the first item in the list
for (int nIndex = list.Count - 1; nIndex >= 0; nIndex--)
{
// if we already have a panel, then add the current panel to a new panel as
a fill and add a splitter
if (main != null)
{
// store a reference to the current control
p = main;

// create a new panel control that will hold the old control and the
current list item
main = new Panel();
main.Dock = DockStyle.Fill;

// add the previous control to the panel
main.Controls.Add(p);

// create a new splitter and add it to the new panel we just created
sp = new Splitter();
sp.Dock = DockStyle.Top;
main.Controls.Add(sp);

// set the previous control to dock at the top and then add it to the new
panel
// we just created
((Control)list[nIndex]).Dock = DockStyle.Top;
main.Controls.Add((Control)list[nIndex]);
}
else
{
// set the main control to the current list item control that
// we are iterating through
((Control)list[nIndex]).Dock = DockStyle.Fill;
main = (Control)list[nIndex];
}
}

// set the dock and height of final control and add it to the
// client panel we want to display it in
main.Dock = DockStyle.Top;
main.Height = (int)(panel1.Height * .5 * list.Count);
panel1.Controls.Add(main);

Although this simply adds 1..N controls with horizontal splitters between
them, it can be customized to do vertical or mixed for any number of controls.

Ashton Hobbs
ApexSQL Edit
http://www.apexsql.com

"C-Services Holland b.v." wrote:
Dennis wrote:
Has anyone really gotten the Docking and Splitter Bars to work for anyting
but the simplest application for two controls and one splitter bar filling
the whole form? If so, can you enlighten my on HOW! I even tried creating
background panels and docking them with the controls on the panels but the
docking order seems to be random! Another useless control from Microsoft I
think!


The way it works for me is thinking ahead and then adding the controls
in the right order. So if I want 2 panels with a vertical splitter I add
1 panel, then the splitter, then the next panel. This seems to work for me.

--
Rinze van Huizen
C-Services Holland b.v.

Nov 21 '05 #26

This discussion thread is closed

Replies have been disabled for this discussion.