GrapeCity.Win.Containers 名前空間 > GcTabBase クラス : ShowPinnedContextMenu プロパティ |
次のサンプルコードは、タブの固定機能の使用例を示します。このサンプルコードを実行するには、以下のコードを 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