Splitter control question.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • JDeats

    Splitter control question.

    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 ClientSizeChang ed and doing something
    like this would work:

    private void frmMyForm_Clien tSizeChanged(ob ject sender, EventArgs e)
    {
    Splitter2.Split Position = 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.

  • ClayB

    #2
    Re: Splitter control question.

    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.Wid th = 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.

    Comment

    Working...