RadSplitContainer

4 posts, 0 answers
  1. Wiktor
    Wiktor avatar
    2 posts
    Member since:
    Aug 2013

    Posted 30 Aug 2013 Link to this post

    Hello

    Help me!

    I have a RadSplitContainer, on RadSplitContainer located 5 splitPanels.
    When the program starts user resizes on RadSplitContainer, splitPanels.

    How can i save the settings, that are made by the user?
  2. Dimitar
    Admin
    Dimitar avatar
    1699 posts

    Posted 04 Sep 2013 Link to this post

    Hi Wiktor,

    Thank you for writing.

    RadSplitContainer does not support such functionality out of the box, however, you can easily implement it by saving and loading the size of the SplitPanels using their SizeInfo property. Here is a sample, which is using the application configuration to save the layout in a StringCollection:
    using Lab.Properties;
    using System.Drawing;
    using System.Windows.Forms;
    using Telerik.WinControls.UI;
      
    namespace Lab.Dock
    {
        public partial class SplitSaveLoadLayoutForm : MainForm
        {
            private RadSplitContainer splitContainer = new RadSplitContainer();
      
            public SplitSaveLoadLayoutForm()
            {
                InitializeComponent();
      
                splitContainer.Dock = DockStyle.Fill;
                splitContainer.Parent = this;
                splitContainer.BringToFront();
      
                for (int i = 0; i < 4; i++)
                {
                    splitContainer.SplitPanels.Add(new SplitPanel());
                }
            }
                 
            protected override void OnButton1Click()
            {
                Settings.Default.SplitPanes = new System.Collections.Specialized.StringCollection();
                foreach (SplitPanel panel in splitContainer.SplitPanels)
                {
                    string size = string.Format("{0}:{1}", panel.Size.Width, panel.Size.Height);
                    Settings.Default.SplitPanes.Add(size);
                }
      
                Settings.Default.Save();
            }
      
            protected override void OnButton2Click()
            {
                if (Settings.Default.SplitPanes == null)
                {
                    return;
                }
      
                int index = 0;
                splitContainer.SuspendLayout();
                foreach (var item in Settings.Default.SplitPanes)
                {
                    splitContainer.SplitPanels[index].SizeInfo.SizeMode = Telerik.WinControls.UI.Docking.SplitPanelSizeMode.Absolute;
                    splitContainer.SplitPanels[index].SizeInfo.AbsoluteSize = Parse(item);
                    index++;
                }
                splitContainer.ResumeLayout(true);
            }
      
            private Size Parse(string size)
            {
                string[] sizeParts = size.Split(':');
                int width = int.Parse(sizeParts[0]);
                int height = int.Parse(sizeParts[1]);
               return new Size(width, height);
            }
        }
    }

    I hope this information helps. Should you have any other questions, I will be glad to assist you.

    Regards,
    Dimitar
    Telerik
     
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
     
  3. Bill
    Bill avatar
    2 posts
    Member since:
    Jun 2013

    Posted 13 Jun in reply to Dimitar Link to this post

    I was able to implement a VB.NET solution for my 4 panel dashboard display (2 rows x 2 columns using 3 RadSplitPanels) using your help. Thanks. Couldn't have done it without this.

    One thing though... in the Parse() method you have the height and width variables backwards, right? When saving the data it's "width:height" but the names of the variables in Parse() makes it look like you read the height out first. But it works because the Size() constructor is expecting the width first. Perhaps two wrongs actually do make a right... if I'm reading this code correctly.

  4. Dimitar
    Admin
    Dimitar avatar
    1699 posts

    Posted 14 Jun Link to this post

    Hello Bill,

    Yes, indeed you are correct. I will change this when possible. 

    Should you have any other questions do not hesitate to ask.

    Regards,
    Dimitar
    Progress Telerik
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top