Adding Arbitrary Controls to a C1TabControl
You can add arbitrary controls to each of your C1TabControl's tab pages using a simple drag-and-drop operation, XHTML, or code. In this topic, you will create a C1TabControl control with two pages and then add an arbitrary control to each of those pages.
In Design View
Complete the following steps:
1. Click
C1TabControl's smart tag () to open the C1TabControl Tasks menu and select TabControl
Designer.
The C1TabControl Designer Form appears.
2. Use the Add Child
Item button to add two pages to the C1TabControl
control.
3. Click OK to close the C1TabControl Designer Form.
4. Select a Button control from the Visual Studio Toolbox and then drag it onto the C1TabPage.
5. Click
C1TabControl's smart tag () and select Move to next page to bring the second tab and tab
page into focus.
6. Select a TextBox control from the Toolbox window and then drag it onto the C1TabPage.
7. Run the project and click on each tab. Observe that a Button control appears on the first tab page, whereas a TextBox control appears on the second.
In Source View
Complete the following steps:
1. Click
C1TabControl's smart tag () to open the C1TabControl Tasks menu and select TabControl
Designer.
The C1TabControl Designer Form appears.
2. Use the Add Child
Item button to add two pages to the C1TabControl
control.
3. Click OK to close the C1TabControl Designer Form.
4. Click the Source tab to enter Source view.
5. Locate the <cc1:C1TabPage> tags for TabPage01 and place the following tag between them:
<asp:Button ID="Button1" runat="server" Text="Hello World!" />
6. Locate the <cc1:C1TabPage> tags for TabPage02 and place the following tag between them:
<asp:TextBox ID="TextBox2" runat="server" />
7. Run the project and click on each tab. Observe that a Button control appears on the first tab page, whereas a TextBox control appears on the second.
In Code
Complete the following steps:
1. Click
C1TabControl's smart tag () to open the C1TabControl Tasks menu and select TabControl
Designer.
The C1TabControl Designer Form appears.
2. Use the Add Child
Item button to add two pages to your C1TabControl.
3. Click OK to close the C1TabControl Designer Form.
4. In the Solution Explorer window, right-click on the project and select View Code to enter the code editor.
5. Create a Button control and add text to it by entering the following code to the Page_Load event:
Dim nuButton As Button = New Button()
nuButton.Text = "Hello World!"
• C#
Button nuButton = new Button();
nuButton.Text = "Hello World!";
6. Create a TextBox control:
Dim nuTextBox As TextBox = New TextBox()
• C#
TextBox nuTextBox = new TextBox();
7. Add the Button control to the first tab page:
C1TabPage1.Controls.Add(nuButton)
• C#
C1TabPage1.Controls.Add(nuButton);
8. Add the TextBox control to the second tab page:
C1TabPage2.Controls.Add(nuTextBox)
• C#
C1TabPage2.Controls.Add(nuTextBox);
9. Run the program and click on each tab. Observe that a Button control appears on the first tab page, whereas a TextBox control appears on the second.
|