Splitter control question.

J

JDeats

I have a WinForm with three Splitter controls on it. The form divides
up in this order: Tab Control (docked to the left): Splitter1:
RichTextBox (docked to the left): Splitter2

After Splliter2 there is some empty space on the form where I have a
few button controls.

When the app starts the form is 800x600, but I need to give the user
the ability to maximize and to resize the form to whatever size they
like. When the occurs I need the splitters to adjust to a percentage
of the screen area so that they remain proportionate regardless of
size. Except I need to keep the area to the far right of the screen
(where the buttons reside) fixed at 120 pixels in length, regardless
of what size the Window is.

I would think trapping on the ClientSizeChanged and doing something
like this would work:

private void frmMyForm_ClientSizeChanged(object sender, EventArgs e)
{
Splitter2.SplitPosition = this.Width - 120;
}

where "this" is the current instance of the Form, however this does
not work. If I maximize the form the area to the right is considerably
larger than 120 pixels and it doesn't seem to ever follow this rule.
 
C

ClayB

Since you have multiple splitters docked left, the position of the
second splitter from the left is determined by the position of the
first splitter from the left and the size of the control (say panel1)
between the first splitter (this.splitter1) and the second splitter.
So, if you want the second splitter (this.splitter2) to be always 120
pixels from the right side of the form, try this code:

this.panel1.Width = this.Width -
this.splitter1.SplitPosition - 120;

This should size the control (panel1) to be exactly the size to
position splitter2 120 units from the right edge of the form.

========================
Clay Burch
Syncfusion, Inc.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top