ComponentOne Tabs for ASP.NET WebForms
Task-Based Help / Creating a C1Tabs Control in Code
In This Topic
    Creating a C1Tabs Control in Code
    In This Topic

    In some instances, you may want to add a C1Tabs control to your project in code. In this topic, you will learn how to create a C1Tabs control with three C1TabPage objects using C# and Visual Basic code.

    Complete the following steps:

    1. Add a PlaceHolder control to your page.
    2. In Design view, double-click the page to add a Page_Load event to the project and to switch to the code editor.
    3. Import the following namespace into your project:

      To write code in Visual Basic

      Visual Basic
      Copy Code
      Imports C1.Web.Wijmo.Controls.C1Tabs
      

      To write code in C#

      C#
      Copy Code
      using C1.Web.Wijmo.Controls.C1Tabs;
      
    4. Create the C1Tabs object, set its Width and Height, and then add it to your project by placing the following code in the Page_Load event:

      To write code in Visual Basic

      Visual Basic
      Copy Code
      Dim NewTabs As C1Tabs = New C1Tabs()
      NewTabs.Width = 300
      NewTabs.Height = 200
      PlaceHolder1.Controls.Add(NewTabs)
      

      To write code in C#

      C#
      Copy Code
      C1Tabs NewTabs = new C1Tabs();
      NewTabs.Width = 300;
      NewTabs.Height = 200;
      PlaceHolder1.Controls.Add(NewTabs);
      
    5. Create three C1TabPage objects and add them to the C1Tabs. This code should also be added to the Page_Load event.

      To write code in Visual Basic

      Visual Basic
      Copy Code
      'Create three C1TabPage objects
      Dim C1TabPage1 As C1TabPage = New C1TabPage()
      Dim C1TabPage2 As C1TabPage = New C1TabPage()
      Dim C1TabPage3 As C1TabPage = New C1TabPage()
      
      'Set the TabPages' 'Text' Property
      C1TabPage1.Text = "C1TabPage1"
      C1TabPage2.Text = "C1TabPage2"
      C1TabPage3.Text = "C1TabPage3"
      
      'Add the three C1TabPage objects to the C1Tabs
      NewTabs.Controls.Add(C1TabPage1)
      NewTabs.Controls.Add(C1TabPage2)
      NewTabs.Controls.Add(C1TabPage3)
      

      To write code in C#

      C#
      Copy Code
      //Create three C1TabPage objects
      C1TabPage C1TabPage1 = new C1TabPage();
      C1TabPage C1TabPage2 = new C1TabPage();
      C1TabPage C1TabPage3 = new C1TabPage();
      
      //Set the TabPages' 'Text' Property'
      C1TabPage1.Text = "C1TabPage1";
      C1TabPage2.Text = "C1TabPage2";
      C1TabPage3.Text = "C1TabPage3";
      
      //Add the three C1Tab objects to the C1Tabs
      NewTabs.Controls.Add(C1TabPage1);
      NewTabs.Controls.Add(C1TabPage2);
      NewTabs.Controls.Add(C1TabPage3);
      
    6. Run the program.

    C1TabsThis Topic Illustrates the Following:

    When your project is run, your C1Tabs control will resemble the following image:

    C1Tabs

    See Also