RadSplitContainer

2 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
    1415 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 height = int.Parse(sizeParts[0]);
                int width = int.Parse(sizeParts[1]);
               return new Size(height, width);
            }
        }
    }

    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. UI for WinForms is Visual Studio 2017 Ready
Back to Top