A multi container to help organise content in a single form app

This is one of the components in rixControls (version available on Nuget currently only for .NET Framework but will be on NET 5 later in the year

Its another take on the splitcontainer/form layout problem, here’s a test form with the control dropped in place:

You can see the lighter grey on the left, right and bottom areas, these will hold user controls which themselves form the layout of your application

I have made some test usercontrols for this demo, here they are in my project:

The one called ucLeftTester1.vb is shown in design mode. These user controls just have a label on them, except one which has a rixConsole

This is the code I use to get started, the name of the multi control is rixMulti1 in this case:

I declare form level variables for the controls that will go into the mutli:

  Private mLeft1 As New ucLeftTester1 With {.Tag = "Left one"}
  Private mLeft2 As New ucLeftTester2 With {.Tag = "Left two"}
  Private mRight1 As New ucRightTester1 With {.Tag = "Team Explorer"}
  Private mRight2 As New ucRightTester2 With {.Tag = "Properties"}
  Private mBottom1 As New ucBottomTester1 With {.Tag = "Bottom one"}
  Private mBottom2 As New ucBottomTester2 With {.Tag = "Bottom two"}

  Private mConsole As New ucConsole

Then in my form load event I pass them to the Multi control like this:

    With RixMulti1
    End With

The StartWith method takes the path to a folder in which the control will save settings, this is the size of each open panel and which panels are open, so that when the application is run again it can start from wherever it left off

This is what the settings file looks like once created:

rixMulti settings file contents

And so given the code above, I should now be able to run the app and interact with the Multi control on the form, and see all of my user controls in the app:

The control rixMulti in full swing

There is a property called BottomMode which enables you to set whether the bottom panel sits between the left and right panels (below), or out on its own (above)

With AutoShrink set to false, you can manually shrink the menu panels by clicking anywhere where there isn’t a button, here I have collapsed the right menu:

Soon as you hover over this menu it pops back out again

By default, this happens automatically – going back to the settings file you can see AutoShrink is set to True (the AutoShrink time is the time in milliseconds after the last detected mouse movement that the shrink occurs)

So all menu items will shrink back to give more space:

Because you declared variables for each user control in the Form, you will be able to access its members via that variable. If you need for any of the user controls to access the form, then just pass the form to the usercontrol in its constructor, this way its very similar to the contents of the user control being within the form itself

You can see below, with all of the panels collapsed (and there could be plenty) – the vast majority of screen space is available:

The Multi is set up with the dark theme I use for most of the controls in rixControls

future versions

I’m waiting on a Visual Studio preview that includes the ability to make user controls with NET 5 (Windows Forms), when that comes through I will be porting rixControls into it

I will add the ability to click and hold a menu button that relates to a panel that isn’t currently visible, and have that panel open up alongside the already open panel, meaning two panels can be opened at the same time for each ‘side’ of the form (left, right & bottom)

The user will have an icon to select whether the two panels are ‘sharing the space of one panel’ or if ‘both panels show in full size’



This component is part of the Nuget package rixControls

It helps you to centralise the code needed to control whether buttons or other controls are enabled or disabled as the state changes in your application

It can optionally allow easy control of who can access a given control too

Multiple controls can be grouped too, so if you have menu items and buttons that do the same thing in your application, they are all controlled in one place

I’ve created a form to demonstrate the use of the Command Manager, it has three buttons and menu items, and two checkboxes which will be used to simulate state changing in your application:

CommandManager test form

When the Odd numbers check box is checked, we will enable the buttons ONE & THREE and the associated menu items too. Similarly, when the Even numbers check box is checked, we will enable button and menu item TWO

If you didn’t already, add rixControls to your project using the Nuget Console:

install-package rixControls

This is a .NET Framework 4.6.1 package

This is the code behind the form (VB) to make it work: (see bottom of article for C Sharp code)

Imports rixControls.rixCommandManager

Public Class frmCommandManager
  Private mCommandManager As CommandManager

#Region "Command Manager"
  Sub InitializeCommandManager()
    mCommandManager = New CommandManager
    mCommandManager.AddCommand("Oddness", AddressOf OnOdd, AddressOf UpdateOdd, New Object() {ToolStripButton1, ToolStripButton3, MenuONEToolStripMenuItem, MenuTHREEToolStripMenuItem})
    mCommandManager.AddCommand("Evenness", AddressOf OnEven, AddressOf UpdateEven, New Object() {ToolStripButton2, MenuTWOToolStripMenuItem})
  End Sub

  Sub OnOdd(c As Command)
    lblMessage.Text = "An odd button was clicked"
  End Sub

  Sub UpdateOdd(c As Command)
    c.Enabled = chkOddNumbers.Checked
  End Sub

  Sub OnEven(c As Command)
    lblMessage.Text = "An even button was clicked"
  End Sub

  Sub UpdateEven(c As Command)
    c.Enabled = chkEvenNumbers.Checked
  End Sub
#End Region

  Private Sub frmCommandManager_Load(sender As Object, e As EventArgs) Handles Me.Load
  End Sub
End Class

Here are the results in the main form:

Odd numbers selected
Even numbers selected

So far you have seen how buttons can be grouped and their logic for (a) execution and (b) accessibility have been centralised into simple code blocks

Another layer of control is allowing specific groups of users access to buttons…

user group access control

I’m going to create an enumeration in my code to hold what will be the currently logged in users’ permissions. This is the enum:

Public Enum Permissions
  NoAccess = 0
  JustAllow = 1
  ONEAccess = 2
  TWOAccess = 4
  THREEAccess = 8
End Enum

You can programmatically assign these permissions to users as bitwise values. The first two (zero and 1) are hard coded in the command manager and so you should always use those in your own enumerations

So, a user who is given permissions of 12 will have access to both THREEAccess [8] and TWOAccess [4] (8 + 4) levels. The individual enum values are given to the command groups in an overload of the AddCommand method, here’s the updated code:

  Sub InitializeCommandManager()
    mCommandManager = New CommandManager
    mCommandManager.AddCommand("ONE", AddressOf OnOdd, AddressOf UpdateOdd, New Object() {ToolStripButton1, MenuONEToolStripMenuItem}, Permissions.ONEAccess)
    mCommandManager.AddCommand("Evenness", AddressOf OnEven, AddressOf UpdateEven, New Object() {ToolStripButton2, MenuTWOToolStripMenuItem}, Permissions.TWOAccess)
    mCommandManager.AddCommand("THREE", AddressOf OnOdd, AddressOf UpdateOdd, New Object() {ToolStripButton3, MenuTHREEToolStripMenuItem}, Permissions.THREEAccess)
  End Sub

In this modified code, we are adding the one and three buttons/menu items separately so that we can properly assign permissions values to them

I added a numeric dropdown control to simulate the user access level:

Whenever the numeric up down control is changed, we’ll pretend that a new user is logging in and we’ll assign the new value to the CommandManager, here is the code:

  Private Sub NumericUpDown1_ValueChanged(sender As Object, e As EventArgs) Handles NumericUpDown1.ValueChanged
    mCommandManager.OperatorValue = NumericUpDown1.Value
  End Sub

That is it! The buttons now are only enabled according to (1) the logic in the Update code block which is able to inspect the state of your application objects to see if the button should be enabled or not and (2) if the current user has access to the permissions that were assigned to the command

c sharp version

I made this up in C Sharp too, here is the full form code:

using rixControls.rixCommandManager;
using System.Windows.Forms;

namespace rixControlsLocalTesterCSharp
    public partial class frmCommandManager : Form
        CommandManager mCommandManager;

        void InitialiseCommandManager()
            mCommandManager = new CommandManager();
            mCommandManager.AddCommand("ONE", OnOdd, UpdateOdd, new object[] {menuONEToolStripMenuItem, toolStripButton1}, (int)Permissions.ONEAccess);
            mCommandManager.AddCommand("TWO", OnEven, UpdateEvent, new object[] {menuTWOToolStripMenuItem, toolStripButton2}, (int)Permissions.TWOAccess);
            mCommandManager.AddCommand("THREE", OnOdd, UpdateOdd, new object[] {menuTHREEToolStripMenuItem, toolStripButton3}, (int)Permissions.THREEAccess);

        void OnOdd(Command c)
            lblMessage.Text = "An odd number button was pressed";
        void UpdateOdd(Command c)
            c.Enabled = chkOddNumbers.Checked;
        void OnEven(Command c)
            lblMessage.Text = "An even number button was pressed";
        void UpdateEvent(Command c)
            c.Enabled = chkEvenNumbers.Checked;

        public frmCommandManager()

        private void frmCommandManager_Load(object sender, System.EventArgs e)

        private void numericUpDown1_ValueChanged(object sender, System.EventArgs e)
            mCommandManager.OperatorValue =(ulong)numericUpDown1.Value;