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

Can't programmatically set position of splitter

6 Answers 773 Views
SplitContainer
This is a migrated thread and some comments may be shown as answers.
Gibran
Top achievements
Rank 1
Gibran asked on 12 Aug 2015, 07:53 PM

Hello,

I have a Windows Form application with a Telerik splitter. I would like to put a limit on how much the splitter can be dragged up. I've been searching high and low for a solution to this problem and I can't find anything. The closest I've come is this site here: http://www.telerik.com/forums/programmatically-setting-size

It recommends setting the AbsoluteSize of one of the SplitPanels. So I set up a moving event handler and did this:

  private void radSplitContainerMain_SplitterMoving(object sender, SplitterCancelEventArgs e)
{
RadSplitContainer splitContainer = (RadSplitContainer)sender;

if (splitter.Location.Y < 420
&& splitter.Location.Y > 0)
{
splitContainer.SplitPanels["splitPanelMainChart"].SizeInfo.AbsoluteSize = new Size(
splitContainer.SplitPanels["splitPanelMainChart"].SizeInfo.AbsoluteSize.Width, 100);
}
}

This doesn't do anything though. I am still able to drag the splitter way below 420 and it doesn't seem to reposition it.

Can anyway help me out?

 

 

6 Answers, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 13 Aug 2015, 07:41 AM
Hi Gibran,

Thank you for writing.

This is the correct way to move the splitter. However, you should use the SplitterMoved event instead of SplitterMoving. The attached video shows how this works on my side (if the splitter is moved in the top part the panel height will be set to 20, if it is dropped in the bottom it will remain there). I used the following code:
void radSplitContainer1_SplitterMoved(object sender, SplitterEventArgs e)
{
    RadSplitContainer splitContainer = (RadSplitContainer)sender;
 
    if (splitContainer.Splitters[0].Location.Y < 420 && splitContainer.Splitters[0].Location.Y > 0)
    {
        splitContainer.SplitPanels[0].SizeInfo.SizeMode = Telerik.WinControls.UI.Docking.SplitPanelSizeMode.Absolute;
        splitContainer.SplitPanels[0].SizeInfo.AbsoluteSize = new Size(0, 20);
    }
}

I hope this helps. Should you have any other questions do not hesitate to ask.
 
Regards,
Dimitar
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Gibran
Top achievements
Rank 1
answered on 13 Aug 2015, 02:27 PM

Thanks Dimitar,

This works. However, as you will notice, I'm also trying to allow the splitter to totally collapse, hence the check for Location.Y > 0.

This is not working. The Y value for when I drag the splitter all the way up, or when I double click on it, is inconsistent. Sometimes it's 202, other times it's 222, and other times it's 413.

Any idea what's going on here?

0
Dimitar
Telerik team
answered on 14 Aug 2015, 01:50 PM
Hi Gibran,

Thank you for writing back.

It appears that it is unnecessary to check if the value is bigger that zero (it will always be bigger). If you want to totally collapse the panel when specific size is reached, you can rewrite the code like this:
void radSplitContainer1_SplitterMoved(object sender, SplitterEventArgs e)
{
    RadSplitContainer splitContainer = (RadSplitContainer)sender;
     
    if (splitContainer.Splitters[0].Location.Y < 420 && splitContainer.Splitters[0].Location.Y > 20)
    {
        splitContainer.SplitPanels[0].SizeInfo.SizeMode = Telerik.WinControls.UI.Docking.SplitPanelSizeMode.Absolute;
        splitContainer.SplitPanels[0].SizeInfo.AbsoluteSize = new Size(0, 20);
    }
    else if (splitContainer.Splitters[0].Location.Y < 20)
    {
        splitContainer.SplitPanels[0].SizeInfo.SizeMode = Telerik.WinControls.UI.Docking.SplitPanelSizeMode.Absolute;
        splitContainer.SplitPanels[0].SizeInfo.AbsoluteSize = new Size(0, 1);
    }
}

I hope this information helps. 

Regards,
Dimitar
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Ras Ran
Top achievements
Rank 2
Iron
Veteran
Iron
answered on 20 Feb 2020, 11:17 AM

how expand  radSplitContainer Spliter programatically ??my  radSplitContainer  containing 3 split panels....i am using Telerik 2015 version....please i need your help 

regards,

Ranees

0
Ras Ran
Top achievements
Rank 2
Iron
Veteran
Iron
answered on 20 Feb 2020, 11:18 AM
how to expand and collapse  radSplitContainer Spliter programatically ??my  radSplitContainer  containing 3 split panels....i am using Telerik 2015 version....please i need your help 
regards,
Ranees
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 24 Feb 2020, 01:39 PM
Hello, Ranees,

In R1 2017 SP1 we introduced public API for performing expand/collapse programmatically. Here is the feedback item for your reference: https://feedback.telerik.com/winforms/1371976-add-radsplitcontainer-expose-api-for-accessing-the-splitter-buttons-and-performing-expand-collapse-programmatically 

Feel free to upgrade to at least this version in order to benefit from the introduced functionality.       

I hope this information helps.

 

Regards,
Dess | Tech Support Engineer, Sr.
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.
Tags
SplitContainer
Asked by
Gibran
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Gibran
Top achievements
Rank 1
Ras Ran
Top achievements
Rank 2
Iron
Veteran
Iron
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or