HeaderPane
Main
Hide
Share Link
Print

Add Method, TabCollectionClass Class

Adds a new tab.

Class: TabCollectionClass
Namespace: Softelvdm.SftTabsNET
Assembly: Softelvdm.SftTabsNET

Syntax

public TabClass Add();
public TabClass Add( string text );
public int Add( TabClass tab );
public TabClass Add(
    string text,
    Image image );
Public Function Add() As TabClass
Public Function Add( ByVal text As String ) As TabClass
Public Function Add( ByVal tab As TabClass ) As Integer
Public Function Add(
    ByVal text As String,
    ByVal image As Image
  ) As TabClass

Parameters

text

The tab's text.

tab

The tab.

image

The tab's image.

Return Value

The new tab. When a TabClass object created by the application is added (tab parameter), the position of the new tab.

Comments

Adds a new tab.

The tab is added after the last tab of the collection. It is created without text, with the given text, or with the given text and image; a TabClass object created by the application can be added instead. The TabCollectionClass.Insert method adds a tab at a given position.

If the control has a client area (SftTabs.ClientArea property), the tab receives its own page (TabClass.Page property).

Examples

C# View entire sample code

        private void buttonAccent_Click(object sender, EventArgs e) {
            colorDialog1.Color = sftTabs1.AccentColor;
            if (colorDialog1.ShowDialog(this) == DialogResult.OK)
                sftTabs1.AccentColor = colorDialog1.Color;
        }

        private void buttonAdd_Click(object sender, EventArgs e) {
            ++addedTabs;
            TabClass tab = sftTabs1.Tabs.Add("Added " + addedTabs.ToString());
            tab.CloseButton = TabCloseButtonOptionalEnum.Always;

            // the page of the new tab is created by the control
            Label info = new Label();
            info.Dock = DockStyle.Fill;
            info.Padding = new Padding(12);
            info.Text = "This tab was added by the Add Tab button. Its close button removes it.";

VB.NET View entire sample code

    ColorDialog1.Color = SftTabs1.AccentColor
    If ColorDialog1.ShowDialog(Me) = DialogResult.OK Then
        SftTabs1.AccentColor = ColorDialog1.Color
    End If
End Sub

Private Sub ButtonAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonAdd.Click
    addedTabs += 1
    Dim tab As TabClass = SftTabs1.Tabs.Add("Added " + addedTabs.ToString())
    tab.CloseButton = TabCloseButtonOptionalEnum.Always

    ' the page of the new tab is created by the control
    Dim info As New Label()
    info.Dock = DockStyle.Fill
    info.Padding = New Padding(12)
    info.Text = "This tab was added by the Add Tab button. Its close button removes it."

See Also TabCollectionClass Class | Classes | SftTabs/NET 3.0