From 83f803adcfd842398875c1db5a87ec672afc576f Mon Sep 17 00:00:00 2001 From: Jaex Date: Sat, 6 Dec 2014 04:06:33 +0200 Subject: [PATCH] TabToTreeView improvements --- HelpersLib/Controls/TabToListView.cs | 2 ++ HelpersLib/Controls/TabToTreeView.Designer.cs | 4 +++- HelpersLib/Controls/TabToTreeView.cs | 15 +++++++++++++-- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/HelpersLib/Controls/TabToListView.cs b/HelpersLib/Controls/TabToListView.cs index 578aef9cd..4c5d1a2d5 100644 --- a/HelpersLib/Controls/TabToListView.cs +++ b/HelpersLib/Controls/TabToListView.cs @@ -24,6 +24,7 @@ #endregion License Information (GPL v3) using System; +using System.ComponentModel; using System.Windows.Forms; namespace HelpersLib @@ -32,6 +33,7 @@ public partial class TabToListView : UserControl { private TabControl mainTabControl; + [Browsable(false)] public TabControl MainTabControl { get diff --git a/HelpersLib/Controls/TabToTreeView.Designer.cs b/HelpersLib/Controls/TabToTreeView.Designer.cs index 0e44d4b1a..30c0c2487 100644 --- a/HelpersLib/Controls/TabToTreeView.Designer.cs +++ b/HelpersLib/Controls/TabToTreeView.Designer.cs @@ -41,9 +41,11 @@ private void InitializeComponent() // // tvMain // - this.tvMain.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.tvMain.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.tvMain.Dock = System.Windows.Forms.DockStyle.Fill; + this.tvMain.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(162))); this.tvMain.FullRowSelect = true; + this.tvMain.HideSelection = false; this.tvMain.Location = new System.Drawing.Point(0, 0); this.tvMain.Name = "tvMain"; this.tvMain.ShowLines = false; diff --git a/HelpersLib/Controls/TabToTreeView.cs b/HelpersLib/Controls/TabToTreeView.cs index bac1d4d52..f92f984e4 100644 --- a/HelpersLib/Controls/TabToTreeView.cs +++ b/HelpersLib/Controls/TabToTreeView.cs @@ -23,6 +23,7 @@ #endregion License Information (GPL v3) +using System.ComponentModel; using System.Windows.Forms; namespace HelpersLib @@ -31,6 +32,7 @@ public partial class TabToTreeView : UserControl { private TabControl mainTabControl; + [Browsable(false)] public TabControl MainTabControl { get @@ -78,12 +80,18 @@ public TabToTreeView() TreeViewSize = 150; } - private void FillTreeView(TreeNodeCollection nodeCollection, TabControl tab) + private void FillTreeView(TreeNodeCollection nodeCollection, TabControl tab, TreeNode parent = null) { if (nodeCollection != null && tab != null) { foreach (TabPage tabPage in tab.TabPages) { + if (parent != null && tabPage.Text == "{Parent}") + { + parent.Tag = tabPage; + continue; + } + TreeNode treeNode = new TreeNode(tabPage.Text); if (!string.IsNullOrEmpty(tabPage.ImageKey)) { @@ -96,7 +104,7 @@ private void FillTreeView(TreeNodeCollection nodeCollection, TabControl tab) { if (control is TabControl) { - FillTreeView(treeNode.Nodes, control as TabControl); + FillTreeView(treeNode.Nodes, control as TabControl, treeNode); break; } } @@ -115,9 +123,12 @@ private void tvMain_AfterSelect(object sender, TreeViewEventArgs e) if (tabPage != null) { + tvMain.BeginUpdate(); tcMain.Visible = true; tcMain.TabPages.Clear(); tcMain.TabPages.Add(tabPage); + tvMain.Focus(); + tvMain.EndUpdate(); } } }