Click here to Skip to main content
15,896,912 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello guys,

I have used a ultrasplitter in my winform apllication to separate two panels.every things works fine but the problem is that i could not change the size of my panels at design time.

I mean i want to change the default location of my ultrasplitter and put it for example at the middle of the form.
Posted
Updated 8-Jul-13 0:22am
v2

1 solution

Maybe this will help ?[^]

Duplicate info from page from link above:

Infragistics UltraSplitter
For my work, as a Graphical User Interface(GUI) developer, I had to replace the Windows Forms SplitContainer for the Infragistics UltraSplitter. Since there is limited documentation about the UltraSplitter I decided to dedicate a blog post about how to implement a UltraSplitter in Windows Forms.

First of all, before replacing the SplitContainer you have to figure out how it works. Luckily for you Microsoft has extensive documentation about the SplitContainer. See for instance MSDN.


SplitContainer
The SplitContainer is one control which seems to be a collection of four different controls. The SplitContainer itself acts like a container Panel with three controls in it. A left panel, the splitter(blue arrow) and a right panel. However note that it is one control.

I started the replacement with an impact analyse. I figured out that the SplitContainer had a lot of coded dependencies. Lots of functionality was programmed to work with the SplitContainer. Therefore I was forced to build a replica of the SplitContainer, who acts just like how the Windows Forms SplitContainers acts.


UltraSplitter
I started with a sample project to make a proof of concept. In the sample project I made a container panel(the blue panel) and added another panel(Panel1) to it. A very important detail is the docking style of first panel(Panel1). Since I wanted the UltraSplitter to be orientated vertically I docked the first panel left. The second control is the UltraSplitter, also docked left and the third control that is added is another panel (Panel 2). Note that the last panel has to be fully docked.

Voila we have made a mock SplitContainer using the UltraSplitter of Infragistics. Note that there are a couple of functional changes between the SplitContainer and the UltraSplitter. When you resize the entire SplitContainer, the panels keep their relative width or height. They auto-size relatively to the SplitContainer. This is different in the UltraSplitter implementation, the panels don't autosize because they are different controls and are only connected through docking properties.

Here is the code:
*Note that this code is part of a greater project. Therefore it contains prefixes and additional functionality which may seem superfluous for you.

C#
public class TSFUltraSplitter
    : Panel
{
    public readonly Panel Panel1;
    public readonly Panel Panel2;
    internal readonly TSFUltraSplitterInternal Splitter;
    public Orientation Orientation { get { return Splitter.Orientation; } }

    public TSFUltraSplitter(Orientation orientation)
    {
        // Since the UltraSplitter does not contain panels for it self, we create 2.
        Panel1 = new Panel();
        Panel2 = new Panel();
        Splitter = new TSFUltraSplitterInternal(orientation);
        // The first panel should copy the Splitters docking property
        Panel1.Dock = Splitter.Dock;
        // The second panel always fills up the residual space.
        Panel2.Dock = DockStyle.Fill;
        // Insert bottom up or right to left.
        this.Controls.Add(Panel2);
        this.Controls.Add(Splitter);
        this.Controls.Add(Panel1);
    }
}

internal class TSFUltraSplitterInternal
    : UltraSplitter
{
    public const int SplitterThickness = 4;
    public readonly Orientation Orientation;

    public TSFUltraSplitterInternal(Orientation orientation)
    {
        Orientation = orientation;
        this.UseFlatMode = DefaultableBoolean.True;
        // The UltraSplitter has a collapse button by default. Nice to have in the future, but for now it is not supported on meta level.
        this.CollapseUIType = Infragistics.Win.Misc.CollapseUIType.None;
        // No border, since that hurts people's eyes.
        this.Appearance.BorderAlpha = Alpha.Transparent;
        // Make the backcolor transparent so that it copies its parent's backcolor.
        this.Appearance.BackColor = Color.Transparent;
        // No gradients
        this.Appearance.BackGradientStyle = GradientStyle.None;
        // When horizontal dock everything to the left, when vertical dock everything to the top.
        if (orientation == System.Windows.Forms.Orientation.Horizontal)
        {
            Dock = DockStyle.Top;
            this.Size = new Size(this.Size.Width, SplitterThickness);
        }
        else
        {
            Dock = DockStyle.Left;
            this.Size = new Size(SplitterThickness, this.Size.Height);
        }
        // Enable HotTracking
        this.UseHotTracking = DefaultableBoolean.True;
    }

    public void SetBackGroundColor(Color color)
    {
        this.Appearance.BackColor = color;
        // Calculate the hover color since it's deduced from the backcolor.
        HotTrackingAppearance.BackColor = TSFLib.ShiftColor(this.Appearance.BackColor, 30);
    }

    protected override void OnParentBackColorChanged(EventArgs e)
    {
        // When the panel changes its backcolor, also change to splitter's backcolor.
        base.OnParentBackColorChanged(e);
        SetBackGroundColor(this.Parent.BackColor);
    }
}
 
Share this answer
 
v2
Comments
M_Mogharrabi 9-Jul-13 3:16am    
Thanks Denis Shemenko,but i could not open this link because of some reasons! Could you please paste it here as your answer or help me in another way?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900