ComponentOne SplitContainer for WinForms
SplitContainer for WinForms Task-Based Help / Changing the C1SplitContainer’s Appearance / Changing the Background Color of Panels
In This Topic
    Changing the Background Color of Panels
    In This Topic

    You can quickly set the background color of the C1SplitterPanels using the C1SplitterPanel.BackColor property. In this topic, you'll learn how to apply different colors to each panel of the C1SplitContainer control in design view and in code.

    In Design View:

    Complete the following steps:

    1. Add the C1SplitContainer to the form.
    2. Click on the C1SplitContainer’s smart tag to open its tasks menu.
    3. Select Edit Panels from the C1SplitContainer Tasks Menu. The C1SplitContainer.Panels Collection Editor appears.
    4. Click Panel 1’s BackColor drop-down arrow, select the Web tab, and choose LightBlue from the list and click OK to save and close the C1SplitContainer.Panels Collection Editor.

    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 new splitcontainer
         Dim split As New C1SplitContainer()
          'create a new panel for the split container
         Dim panel1 As New C1SplitterPanel()
            'add the panel to the splitcontainer
         split.Panels.Add(panel1)
           panel1.Text = "Panel 1"
           ‘set Panel 1 backcolor to lightblue
         Panel.BackColor = Color.LightBlue
          'add the splitcontainer
         Controls.Add(split)
      End Sub
      

      To write code in C#

      C#
      Copy Code
      private void Form1_Load(object sender, EventArgs e)
      {
         //create new splitcontainer
         C1SplitContainer split = new C1SplitContainer();
          //create a new panel for the split container
         C1SplitterPanel panel1 = new C1SplitterPanel();
          //add panel1 to the splitcontainer
         split.Panels.Add(panel1);
         panel1.Text = "Panel 1";
         //set Panel 1 backcolor to lightblue
         Panel.BackColor = Color.LightBlue;
         //add the splitcontainer
         Controls.Add(split);
      }
      
    4. Run the program.

    This Topic Illustrates the Following:

    The image below shows Panel 1 with a LightBlue background.


    See Also