PowerTools PlusPak for Windows Forms 8.0J
PinnedStyle プロパティ (GcTabBase)
使用例 

固定されたタブの表示方法を示すタブスタイルを取得または設定します。
構文
Public Overridable Property PinnedStyle As TabStyle
public virtual TabStyle PinnedStyle {get; set;}

プロパティ値

固定されたタブのスタイルを示す TabStyle オブジェクト。
解説
固定されたタブは、その他すべての固定されていないタブの前に表示されます。GcTabPage.IsPinned または GcMdiTabControl.GetIsPinned を使用して、固定状態を取得できます。固定されたタブには PinnedStyle が適用されるので、固有の外観を与えることができます。ユーザーは、ShowPinnedContextMenutrue の場合にはコンテキストメニューによって、AllowDragToPinTab および AllowDragToUnpinTabtrue の場合にはドラッグ&ドロップによって、タブを固定または固定解除できます。タブの固定状態を変更する前に、GcTabControl.TabPinnedChanging または GcMdiTabControl.TabPinnedChanging イベントが発生します。必要であれば、System.ComponentModel.CancelEventArgs.Cancel プロパティを true に設定することで、固定または固定解除アクションをキャンセルできます。アクションが実行された場合は、その後に GcTabControl.TabPinnedChanged または GcMdiTabControl.TabPinnedChanged イベントが発生します。
使用例

次のサンプルコードは、タブの固定機能の使用例を示します。このサンプルコードを実行するには、以下のコードを System.Windows.Forms.Form プロジェクトに追加し、ここで作成したメソッドをコンストラクターまたはフォーム上の別のメソッドから呼び出します。

public void CreateTabControlPinnedTabs()
{
    // Create a GcTabControl.
    GcTabControl gcTabControl = new GcTabControl();

    // Set the size and location of gcTabControl.
    gcTabControl.Size = new Size(200, 200);
    gcTabControl.Location = new Point(10, 10);

    // Add some tab pages to gcTabControl.
    gcTabControl.TabPages.AddRange(new GcTabPage[]
    { 
        new GcTabPage("page1"),
        new GcTabPage("page2"),
        new GcTabPage("page3"),
        new GcTabPage("page4"),
    });

    // Handle the TabPinnedChanged event.
    gcTabControl.TabPinnedChanged += new Containers.TabControlEventHandler(gcTabControl_TabPinnedChanged);

    // Allow to pin or unpin tab by context menu or drag-drop.
    gcTabControl.ShowPinnedContextMenu = true;
    gcTabControl.AllowDragDrop = true;
    gcTabControl.AllowDragToPinTab = true;
    gcTabControl.AllowDragToUnpinTab = true;

    // Set the style for pinned tabs.
    gcTabControl.PinnedStyle.ForeColor = Color.Red;

    // Pin a tab.
    gcTabControl.TabPages[3].IsPinned = true;

    this.Controls.Add(gcTabControl);
}

private void gcTabControl_TabPinnedChanged(object sender, Containers.TabControlEventArgs e)
{
    // Change the text of tab.
    if (e.Action == Containers.TabControlAction.Pinned)
    {
        e.TabPage.Text += "_Pinned";
    }
    else if (e.Action == Containers.TabControlAction.Unpinned)
    {
        e.TabPage.Text = e.TabPage.Text.Substring(0, 5);
    }
}
Public Sub CreateTabControlPinnedTabs()
    ' Create a GcTabControl.
    Dim gcTabControl As New GcTabControl()

    ' Set the size and location of gcTabControl.
    gcTabControl.Size = New Size(200, 200)
    gcTabControl.Location = New Point(10, 10)

    ' Add some tab pages to gcTabControl.
    gcTabControl.TabPages.AddRange(New GcTabPage() {New GcTabPage("page1"), New GcTabPage("page2"), New GcTabPage("page3"), New GcTabPage("page4")})

    ' Handle the TabPinnedChanged event.
    AddHandler gcTabControl.TabPinnedChanged, AddressOf gcTabControl_TabPinnedChanged

    ' Allow to pin or unpin tab by context menu or drag-drop.
    gcTabControl.ShowPinnedContextMenu = True
    gcTabControl.AllowDragDrop = True
    gcTabControl.AllowDragToPinTab = True
    gcTabControl.AllowDragToUnpinTab = True

    ' Set the style for pinned tabs.
    gcTabControl.PinnedStyle.ForeColor = Color.Red

    ' Pin a tab.
    gcTabControl.TabPages(3).IsPinned = True

    Me.Controls.Add(gcTabControl)
End Sub

Private Sub gcTabControl_TabPinnedChanged(ByVal sender As Object, ByVal e As Containers.TabControlEventArgs)
    ' Change the text of tab.
    If e.Action = Containers.TabControlAction.Pinned Then
        e.TabPage.Text += "_Pinned"
    ElseIf e.Action = Containers.TabControlAction.Unpinned Then
        e.TabPage.Text = e.TabPage.Text.Substring(0, 5)
    End If

End Sub
プラットフォーム

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

参照

GcTabBase クラス
GcTabBase メンバ

Send Feedback