This is a migrated thread and some comments may be shown as answers.

Change SplitPanel collapse direction

16 Answers 709 Views
SplitContainer
This is a migrated thread and some comments may be shown as answers.
Rodrigo Cesar
Top achievements
Rank 1
Rodrigo Cesar asked on 12 Dec 2014, 05:19 PM
How can I change SplitPanel collapse direction.
Using RadSplitContainer with 2 panels I need panel 2 collapsable to down, not up, hidding panel 1!

16 Answers, 1 is accepted

Sort by
0
Hristo
Telerik team
answered on 15 Dec 2014, 01:32 PM
Hi Rodrigo,

Thank you for writing.

The SplitterElement class defines buttons responsible for collapsing and expanding the SplitPanel element. In your case we need to override the default behavior of the buttons in the SplitterElement. We can achieve that by subscribing to PropertyChanged and PanelCollapsing events. Please see the code snippet below:
public Form1()
{
    InitializeComponent();
 
    this.Load += Form1_Load;
    this.radSplitContainer.PanelCollapsing += radSplitContainer_PanelCollapsing;
 
    this.radSplitContainer.EnableCollapsing = true;
    this.radSplitContainer.UseSplitterButtons = true;
}
 
private void Form1_Load(object sender, EventArgs e)
{
    var splitter = this.radSplitContainer.Splitters.First();
 
    splitter.NextNavigationButton.PropertyChanged += NextNavigationButton_PropertyChanged;
    splitter.NextNavigationButton.Visibility = ElementVisibility.Collapsed;
     
    splitter.PrevNavigationButton.PropertyChanged += NextNavigationButton_PropertyChanged;
    splitter.PrevNavigationButton.Visibility = ElementVisibility.Visible;
}
 
private void NextNavigationButton_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
    RadButtonElement btn = sender as RadButtonElement;
    if (e.PropertyName == "Visibility")
    {
        Console.WriteLine(btn.Class);
    }
    if (e.PropertyName == "Visibility" && btn.Class == "PrevDownSplitterThumb")
    {
        if (btn.Visibility == ElementVisibility.Collapsed)
        {
          
            btn.Visibility = ElementVisibility.Visible;
            btn.AngleTransform = 0f;
        }
        
    }
 
    if (e.PropertyName == "Visibility" && btn.Visibility == ElementVisibility.Visible && btn.Class == "NextUpSplitterThumb")
    {
        btn.Visibility = ElementVisibility.Collapsed;
    }
}
 
private void radSplitContainer_PanelCollapsing(object sender, Telerik.WinControls.UI.RadSplitContainer.PanelCollapsingEventArgs e)
{
    var splitter = this.radSplitContainer.Splitters.First();
    splitter.PrevNavigationButton.AngleTransform = 180f;
}

I hope that this information will help. Should you have further questions please do not hesitate to write back.

Regards,
Hristo
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Rodrigo Cesar
Top achievements
Rank 1
answered on 18 Dec 2014, 05:23 PM
It works!
Thanks a lot!
0
Daniel
Top achievements
Rank 1
answered on 06 Feb 2015, 05:53 PM
And how can i change it if collapse direction are horizontal?.
I tried this code up/down and it worked, but it doesn't left/right.

Thanks for help.
0
Hristo
Telerik team
answered on 10 Feb 2015, 01:42 PM
Hi Daniel,

Thank you for writing back.

You could use the approach as suggested in my previous answer, where we had reversed the direction of vertically stacked panels. Now we can follow the same logic and perform slight modifications when hiding the buttons:
public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
 
        this.radSplitContainer1.EnableCollapsing = true;
        this.radSplitContainer1.UseSplitterButtons = true;
 
        this.Load += Form1_Load;
        this.radSplitContainer1.PanelCollapsing += radSplitContainer1_PanelCollapsing;
    }
 
    private void Form1_Load(object sender, EventArgs e)
    {
        SplitterElement splitter = this.radSplitContainer1.Splitters.First();
 
        splitter.NextNavigationButton.PropertyChanged += NextNavigationButton_PropertyChanged;
        splitter.NextNavigationButton.Visibility = ElementVisibility.Visible;
 
        splitter.PrevNavigationButton.PropertyChanged += NextNavigationButton_PropertyChanged;
        splitter.PrevNavigationButton.Visibility = ElementVisibility.Collapsed;
    }
 
    private void NextNavigationButton_PropertyChanged(object sender, PropertyChangedEventArgs e)
    {
        RadButtonElement btn = sender as RadButtonElement;
        if (e.PropertyName == "Visibility" && btn.Class == "NextUpSplitterThumb")
        {
            if (btn.Visibility == ElementVisibility.Collapsed)
            {
 
                btn.Visibility = ElementVisibility.Visible;
                btn.AngleTransform = 0f;
            }
        }
 
        if (e.PropertyName == "Visibility" && btn.Visibility == ElementVisibility.Visible && btn.Class == "PrevDownSplitterThumb")
        {
            btn.Visibility = ElementVisibility.Collapsed;
        }
    }
 
    void radSplitContainer1_PanelCollapsing(object sender, RadSplitContainer.PanelCollapsingEventArgs e)
    {
        SplitterElement splitter = this.radSplitContainer1.Splitters.First();
        splitter.NextNavigationButton.AngleTransform = 180f;
    }
}

I am also sending you gif file with the result on my end.

I hope this helps. Should you have further questions please do not hesitate to write back.

Regards,
Hristo Merdjanov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Ras Ran
Top achievements
Rank 2
Iron
Veteran
Iron
answered on 18 Feb 2020, 06:24 AM

hiii....i have a problem with SplitContainer  SplitPanel....my SplitContainer  containing three SplitPanels...i set each panel size mode to "Absolute"....i this case expand and collapse of a split panel is working perfectly....but when i am closing the rad form i kept Split panel absolute height and width to a xml....when i am reopening my rad form i set absolute height and width from xml....i this case expand and collapse of a split panel is not working properly....i there any way to solve this problem

Please check the attached gif image 

Regards 

Ras Ran

 

 

0
Hristo
Telerik team
answered on 20 Feb 2020, 03:36 PM

Hi Ras Ran, 

The reported behavior does not appear to be related to the discussed in the thread scenario. From your message I understand that you are persisting the layout of the split container and upon recreating the form you are restoring it. If that is the case, please check if you are also setting the SizeMode property of the panels to be Absolute.  In case the issue persists and you would like us to investigate it, please open a support ticket and send us an example reproducing the behavior on your end.

I hope this will help. Let me know if you need further assistance.

Regards,
Hristo
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Ras Ran
Top achievements
Rank 2
Iron
Veteran
Iron
answered on 20 Feb 2020, 04:45 PM

Hii Hristo, i hope u understand my question....iam setting the panel container size programmatically ...i just want to change the splitter button direction(if its expended or collapsed ) programmatically at the run time....who you please give a Sollution for this ? 

Iam using telerik 2015 version 

regards ,

Ranees

0
Hristo
Telerik team
answered on 21 Feb 2020, 07:21 AM

Hi Ranees,

The approach discussed in the thread suggests a possible solution. Please note, however, that this is custom behavior which is not by design supported by the control. In this respect it may not cover all possible cases. If not already, please give it a try. If you are experiencing issues you can share a code snippet according to your local setup.

Regards,
Hristo
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Tiago
Top achievements
Rank 1
answered on 03 May 2020, 10:40 PM

Hi Hristo,

How can I have a minimum width on my SplitPanel and close it all the way when I click the collapse button?

I tried to set minimum width on PanelCollapsing event but with no success

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 06 May 2020, 01:46 PM
Hello, Tiago, 

In order to enable the collapsing buttons, it is necessary to set the EnableCollapsing and the UseSplitterButtons property to true. As to the question about sizing the SplitPanel, it is suitable to use SplitPanelSizeMode.Absolute and specify the SplitPanel.SizeInfo.MinimumSize. However, this will prevent the panel from collapsing.

The possible solution in this case is to use the following approach which result is illustrated in the attached gif file:
        private void RadForm1_Load(object sender, EventArgs e)
        {
            this.radSplitContainer1.EnableCollapsing = true;
            this.radSplitContainer1.UseSplitterButtons = true;
            this.splitPanel1.SizeInfo.SizeMode = SplitPanelSizeMode.Absolute;
            this.splitPanel1.SizeInfo.AbsoluteSize= new Size(30, 0);

            this.radSplitContainer1.PanelCollapsing+=radSplitContainer1_PanelCollapsing;
              
        } 
        private void radSplitContainer1_PanelCollapsing(object sender, RadSplitContainer.PanelCollapsingEventArgs e)
        {
            this.radSplitContainer1.PanelCollapsing -= radSplitContainer1_PanelCollapsing;

            this.splitPanel1.SizeInfo.SizeMode = SplitPanelSizeMode.Auto;
            this.radSplitContainer1.MoveSplitter(this.radSplitContainer1.Splitters[0], RadDirection.Left);
            this.radSplitContainer1.MoveSplitter(this.radSplitContainer1.Splitters[0], RadDirection.Left);
            this.radSplitContainer1.PanelCollapsing += radSplitContainer1_PanelCollapsing;
        }

I hope this information helps.

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
Tiago
Top achievements
Rank 1
answered on 06 May 2020, 04:37 PM

Hi Dess, thanks for the response,

In example gif that you attached I want to collapse the red panel and when it's not collapse I want it to have a minimum width.

resetting the minimum size in _PanelCollapsing event *this.splitPanel1.SizeInfo.MinimumSize = new Size();* does the trick to collapse it, but setting again the minimum size inside _PropertyChanged event in the code that Hristo supplied breaks the collapse

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 11 May 2020, 09:01 AM

Hello, Tiago, 

In order to collapse the red panel in a similar way and keep a minimum width for it, it is suitable to follow an identical approach: 

        private void RadForm1_Load(object sender, EventArgs e)
        {
            this.radSplitContainer1.EnableCollapsing = true;
            this.radSplitContainer1.UseSplitterButtons = true;
            this.splitPanel3.SizeInfo.SizeMode = SplitPanelSizeMode.Absolute;
            this.splitPanel3.SizeInfo.AbsoluteSize= new Size(30, 0);

            this.radSplitContainer1.PanelCollapsing+=radSplitContainer1_PanelCollapsing;
              
        } 
        private void radSplitContainer1_PanelCollapsing(object sender, RadSplitContainer.PanelCollapsingEventArgs e)
        {
            this.radSplitContainer1.PanelCollapsing -= radSplitContainer1_PanelCollapsing;

            this.splitPanel3.SizeInfo.SizeMode = SplitPanelSizeMode.Auto;
            this.radSplitContainer1.MoveSplitter(this.radSplitContainer1.Splitters[1], RadDirection.Right );
            this.radSplitContainer1.MoveSplitter(this.radSplitContainer1.Splitters[1], RadDirection.Right);
            this.radSplitContainer1.PanelCollapsing += radSplitContainer1_PanelCollapsing;
        }

The obtained result is illustrated in the gif file. Note that this is just a sample approach and it may not cover all possible cases. Feel free to modify and extend it in a way which suits your requirements best. Additional information about sizing panels in RadSplitContainer is available here: 
https://docs.telerik.com/devtools/winforms/controls/splitcontainer/building-a-layout-of-radsplitcontainers-programmatically
https://docs.telerik.com/devtools/winforms/controls/splitcontainer/building-advanced-layouts

I hope this information helps.

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
Tiago
Top achievements
Rank 1
answered on 13 May 2020, 04:23 PM

Hi Dess,
I can't get it to work with you code :/ 

I made an empty project with the splitter container and the default settings and added you code, the panel wont collapse :/

 

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 15 May 2020, 07:50 AM
Hello, Tiago, 

I have attached my sample project containing the white, green and red split panels which achieved result was illustrated in the gif file from my previous reply.  

I hope this information helps.

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
Tiago
Top achievements
Rank 1
answered on 19 May 2020, 05:22 PM

Hi Dess,

Your example works with 3 panels, but if you remove one it no longer works, also the AbsoluteSize does nothing for the minimum width  right? the user can still change its width below 30

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 22 May 2020, 10:27 AM
Hello, Tiago,  

The SplitPanel.MinimumSize property is inherited from the base class RadControl. It is necessary to set the SplitPanel.SizeInfo.MinimumSize instead. Please refer to the attached gif file: 
            this.splitPanel3.SizeInfo.MinimumSize = new Size(30, 0);
            this.splitPanel3.SizeInfo.SizeMode = SplitPanelSizeMode.Absolute;
            this.splitPanel3.SizeInfo.AbsoluteSize = new Size(30, 0);

If you have only two SplitPanels, you will notice that the splitter direction is opposite compared to the case with three panels. Hence, you can collapse the yellow panel in this case:

That is why the layout is different in this case and the obtained behavior accordingly. Feel free to use three panels in case you want the right panel to be collapsed via the splitter considering the correct direction. You can always manage the middle panel's size in such a way that it would be invisible.

I believe that you find this information helpful for build your custom layout.

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Tags
SplitContainer
Asked by
Rodrigo Cesar
Top achievements
Rank 1
Answers by
Hristo
Telerik team
Rodrigo Cesar
Top achievements
Rank 1
Daniel
Top achievements
Rank 1
Ras Ran
Top achievements
Rank 2
Iron
Veteran
Iron
Tiago
Top achievements
Rank 1
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or