ComponentOne SplitContainer for WinForms
SplitContainer for WinForms Task-Based Help / Adding Content to the Splitter Panels / Adding Arbitrary Controls to the C1SplitterPanel
In This Topic
    Adding Arbitrary Controls to the C1SplitterPanel
    In This Topic

    You can add arbitrary controls to each C1SplitterPanel of the C1SplitContainer control using a simple drag-and-drop operation. In this topic, you will add a Button control to Panel1 and a TextBox control to Panel2.

    In Design View:

    Complete the following steps:

    1. Add C1SplitContainer to the form.
    2. Click on the C1SplitContainer’s smart tag to open its tasks menu.
    3. Select Add Panel twice to add two panels to the C1SplitContainer control.
    4. Click inside Panel 1 and open its tasks menu. The C1SplitterPanel Tasks menu appears.
    5. Select a Button control from the Visual Studio Toolbox and drag it into the Panel 1.

    Select a TextBox control from the Visual Studio Toolbox and drag it into Panel 2.

    In Code View:

    Complete the following steps:

    1. Add the C1.Win.C1SplitContainer.dll reference to your project.
    2. Declare the following C1.Win.C1SplitContainer namespace at the top of your code page:

      Visual Basic

      Visual Basic
      Copy Code
      Imports C1.Win.C1SplitContainer
      

      To write code in C#

      C#
      Copy Code
      using C1.Win.C1SplitContainer;
      
    3. Add the following code in the Form_Load event:

      Visual Basic

      Visual Basic
      Copy Code
      Private Sub Form1_Load(sender As Object, e As EventArgs)
         ' Create a Button control and add text to it
         Dim button1 As New Button()
         button1.Text = "Hello World!"
          ' Create a TextBox control
         Dim textbox1 As New TextBox()
          'create new splitcontainer
         Dim split As New C1SplitContainer()
          'create a new panel for the split container
         Dim panel1 As New C1SplitterPanel()
         Dim panel2 As New C1SplitterPanel()
          'add panel1 to the splitcontainer
         split.Panels.Add(panel1)
         split.Panels.Add(panel2)
          panel1.Text = "Panel 1"
         panel2.Text = "Panel 2"
          'add the splitcontainer
         Controls.Add(split)
          'add the button control to panel1
         panel1.Controls.Add(button1)
          'add the textbox control to panel2
         panel2.Controls.Add(textbox1)
      End Sub
      

      To write code in C#

      C#
      Copy Code
      private void Form1_Load(object sender, EventArgs e)
      {
         // Create a Button control and add text to it
         Button button1 = new Button();
         button1.Text = "Hello World!";
          // Create a TextBox control
         TextBox textbox1 = new TextBox();
          //create new splitcontainer
         C1SplitContainer split = new C1SplitContainer();
          //create a new panel for the split container
         C1SplitterPanel panel1 = new C1SplitterPanel();
         C1SplitterPanel panel2 = new C1SplitterPanel();
          //add panel1 to the splitcontainer
         split.Panels.Add(panel1);
         split.Panels.Add(panel2);
          panel1.Text = "Panel 1";
         panel2.Text = "Panel 2";
         //add the splitcontainer
         Controls.Add(split);
          //add the button control to panel1
         panel1.Controls.Add(button1);
          //add the textbox control to panel2
         panel2.Controls.Add(textbox1); 
      }
      

    The following graphic depicts a C1SplitContainer control with a Button control in Panel1 and a TextBox control in Panel2.


    See Also