Splitter Class

G

Guest

Heya

I am having trouble using a Splitter to divide a Frame horizontally. For some reason the top panel automatically fills the entire Frame area, while the splitter lets me move the bottom panel up over the top panel. What I expect to occur is to have both panels resize to fit the available space when I adjust the Splitter. I attempted to implement this code myself only to have very weird behavior (which mostlikely had to do with the order the events were firing). Here's the layout for the frame

this.splitter1.Dock = System.Windows.Forms.DockStyle.Bottom
this.splitter1.Location = new System.Drawing.Point(0, 246)
this.splitter1.Name = "splitter1"
this.splitter1.Size = new System.Drawing.Size(736, 3)
this.splitter1.TabIndex = 2
this.splitter1.TabStop = false
this.splitter1.SplitterMoved += new System.Windows.Forms.SplitterEventHandler(this.splitter1_SplitterMoved)


this.dgOrders.DataMember = ""
this.dgOrders.Dock = System.Windows.Forms.DockStyle.Fill
this.dgOrders.HeaderForeColor = System.Drawing.SystemColors.ControlText
this.dgOrders.ImeMode = System.Windows.Forms.ImeMode.NoControl
this.dgOrders.Location = new System.Drawing.Point(0, 58)
this.dgOrders.Name = "dgOrders"
this.dgOrders.ReadOnly = true
this.dgOrders.Size = new System.Drawing.Size(736, 343)
this.dgOrders.TabIndex = 0
this.dgOrders.TableStyles.AddRange(new System.Windows.Forms.DataGridTableStyle[] {this.dataGridTableStyle1})

this.axWebBrowser.ContainingControl = this
this.axWebBrowser.Dock = System.Windows.Forms.DockStyle.Fill
this.axWebBrowser.Enabled = true
this.axWebBrowser.Location = new System.Drawing.Point(0, 0)
this.axWebBrowser.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axWebBrowser.OcxState")))
this.axWebBrowser.Size = new System.Drawing.Size(736, 152)
this.axWebBrowser.TabIndex = 2

I'd appreciate any help anyone can give me.

~~K
 
S

Stoitcho Goutsev \(100\) [C# MVP]

Hi Kevin,
reading your snippet I personaly can't say what the problem is. However I
believe the problem is in the order of creating the controls.

If you want to have to panels and splitter in between here is the right
order to desing the form:

1. Add the panel on the bottom and set the Dock property to 'Bottom'
2. Add the splitter and set its Dock property to 'Bottom' as well
3. Add the panel on top and set its property to 'Fill'

Note: all three control have to be parented by the same control.The order of
creation does matter.

If you have already designed your form you can use 'Bring to Fron' and Send
to Back' commands from the controls' context menu to change the order of
creation. In your case in the bottom has to be the panel docked 'Bottom',
the splitter and on the top the secon panel docked 'Fill'.


--
HTH
B\rgds
Stoitcho Goutsev (100) [C# MVP]

Kevin Z Grey said:
Heya,

I am having trouble using a Splitter to divide a Frame horizontally.
For some reason the top panel automatically fills the entire Frame area,
while the splitter lets me move the bottom panel up over the top panel.
What I expect to occur is to have both panels resize to fit the available
space when I adjust the Splitter. I attempted to implement this code myself
only to have very weird behavior (which mostlikely had to do with the order
the events were firing). Here's the layout for the frame:
this.splitter1.Dock = System.Windows.Forms.DockStyle.Bottom;
this.splitter1.Location = new System.Drawing.Point(0, 246);
this.splitter1.Name = "splitter1";
this.splitter1.Size = new System.Drawing.Size(736, 3);
this.splitter1.TabIndex = 2;
this.splitter1.TabStop = false;
this.splitter1.SplitterMoved += new System.Windows.Forms.SplitterEventHandler(this.splitter1_SplitterMoved);


this.dgOrders.DataMember = "";
this.dgOrders.Dock = System.Windows.Forms.DockStyle.Fill;
this.dgOrders.HeaderForeColor = System.Drawing.SystemColors.ControlText;
this.dgOrders.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.dgOrders.Location = new System.Drawing.Point(0, 58);
this.dgOrders.Name = "dgOrders";
this.dgOrders.ReadOnly = true;
this.dgOrders.Size = new System.Drawing.Size(736, 343);
this.dgOrders.TabIndex = 0;
this.dgOrders.TableStyles.AddRange(new
System.Windows.Forms.DataGridTableStyle[] {this.dataGridTableStyle1});
 
G

Guest

Hi Stoitcho

Thanks for the response. Thats precisely how I have done it. The layout also appears fine at first glance (Panel on top, Splitter, Panel on bottom), but at closer evaluation, the top panel actually extends below the splitter such that it is filling the entire Frame area behind the splitter and bottom panel. What I would expect it to do is to resize the top and bottom controls accordingly so that they only fill in the visible areas
FrameHeight = TopHeight + SplitterHeight + BottomHeigh
What I have now is
TopHeight = FrameHeight, with the Splitter and Bottom appearing to overlay the Top panel

I'll see if I can whip up a demo to show you what I mean..

~~K
 
G

Guest

Hi Stoitcho

You're right, it was as simple as doing a BringToFront on the top panel. Funny thing is that I knew about this fix but I thought it was dealing only with the docked pair on the bottom. This makes sense now

~~K
 
S

Stoitcho Goutsev \(100\) [C# MVP]

Hi Kevin,

Bare in mind that the controls layout their children backwards, that is the
last in the Controls list first. This means that the fill docked has to be
the first control in the list. This you should keep in mind when creating
controls form code. When you add controls using the designer it inserts the
controls always at index 0 (maybe except some special controls like
Statusbar for example).

I'm telling you that because I got the imression that a lot of progrmmers
thing that the designer takes into account the docking property. The truth
is it doesn't. Only the order of placing the controls matter

--
B\rgds
Stoitcho Goutsev (100) [C# MVP]

Kevin Z Grey said:
Hi Stoitcho,

You're right, it was as simple as doing a BringToFront on the top
panel. Funny thing is that I knew about this fix but I thought it was
dealing only with the docked pair on the bottom. This makes sense now.
 
Top