Multiple SplitPanel Collapse button

3 posts, 1 answers
  1. Dinda
    Dinda avatar
    2 posts
    Member since:
    Nov 2016

    Posted 22 Nov 2016 Link to this post

    I can change split panel collapse direction to left or right like this. But can I have both splitter buttons (left and right direction) on RadSplitContainer with only 2 SplitPanels?

    I noticed that if the RadSplitContainer had more than 3 panels, the splitter button showed 2 buttons (left and right direction)

     

  2. Answer
    Hristo
    Admin
    Hristo avatar
    1028 posts

    Posted 23 Nov 2016 Link to this post

    Hi Dinda,

    Thank you for writing.

    The example in the mentioned other thread changes the direction. Since you need to have both of the splitter buttons visible you need to use the suggested approach for the hidden button. 

    I have extended the example to handle a scenario with multiple panels. Please see below: 
    public partial class RadForm1 : RadForm
    {
        public RadForm1()
        {
            InitializeComponent();
     
            this.radSplitContainer1.EnableCollapsing = true;
            this.radSplitContainer1.UseSplitterButtons = true;
     
            this.radSplitContainer1.PanelCollapsing += radSplitContainer1_PanelCollapsing;
        }
     
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
     
            SplitterElement firstSplitter = this.radSplitContainer1.Splitters[0];
            firstSplitter.Tag = "First";
            firstSplitter.NextNavigationButton.PropertyChanged += NextNavigationButton_PropertyChanged;
            firstSplitter.NextNavigationButton.Visibility = ElementVisibility.Visible;
     
            SplitterElement lastSplitter = this.radSplitContainer1.Splitters[2];
            lastSplitter.Tag = "Last";
            lastSplitter.PrevNavigationButton.PropertyChanged += PrevNavigationButton_PropertyChanged;
            lastSplitter.PrevNavigationButton.Visibility = ElementVisibility.Visible;
        }
     
        private void PrevNavigationButton_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            RadButtonElement btn = sender as RadButtonElement;
            if (e.PropertyName == "Visibility" && btn.Class == "PrevDownSplitterThumb")
            {
                if (btn.Visibility == ElementVisibility.Collapsed)
                {
     
                    btn.Visibility = ElementVisibility.Visible;
                    btn.AngleTransform = 0f;
                }
            }
        }
     
        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;
                }
            }
        }
     
        private void radSplitContainer1_PanelCollapsing(object sender, RadSplitContainer.PanelCollapsingEventArgs e)
        {
            SplitterElement splitter = (SplitterElement)sender;
            if (splitter.Tag == null)
            {
                return;
            }
     
            if ((e.Direction == RadDirection.Right && splitter.Tag == "First"))
            {
                splitter.NextNavigationButton.AngleTransform = 180f;
            }
     
            if (e.Direction == RadDirection.Left && splitter.Tag == "Last")
            {
                splitter.PrevNavigationButton.AngleTransform = 180f;
            }
        }
    }

    I am also attaching a short video showing 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 by Progress
    Telerik UI for WinForms is ready for Visual Studio 2017 RC! Learn more.
  3. Dinda
    Dinda avatar
    2 posts
    Member since:
    Nov 2016

    Posted 23 Nov 2016 in reply to Hristo Link to this post

    Hi Hristo,

    Thank you for your detailed answer. It works!!

Back to Top