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
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.
Dimitar
Telerik
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?
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
how expand radSplitContainer Spliter programatically ??my radSplitContainer containing 3 split panels....i am using Telerik 2015 version....please i need your help
regards,
Ranees
regards,
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