TabToTreeView improvements

This commit is contained in:
Jaex 2014-12-06 04:06:33 +02:00
parent b02c9c091e
commit 83f803adcf
3 changed files with 18 additions and 3 deletions

View file

@ -24,6 +24,7 @@
#endregion License Information (GPL v3) #endregion License Information (GPL v3)
using System; using System;
using System.ComponentModel;
using System.Windows.Forms; using System.Windows.Forms;
namespace HelpersLib namespace HelpersLib
@ -32,6 +33,7 @@ public partial class TabToListView : UserControl
{ {
private TabControl mainTabControl; private TabControl mainTabControl;
[Browsable(false)]
public TabControl MainTabControl public TabControl MainTabControl
{ {
get get

View file

@ -41,9 +41,11 @@ private void InitializeComponent()
// //
// tvMain // 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.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.FullRowSelect = true;
this.tvMain.HideSelection = false;
this.tvMain.Location = new System.Drawing.Point(0, 0); this.tvMain.Location = new System.Drawing.Point(0, 0);
this.tvMain.Name = "tvMain"; this.tvMain.Name = "tvMain";
this.tvMain.ShowLines = false; this.tvMain.ShowLines = false;

View file

@ -23,6 +23,7 @@
#endregion License Information (GPL v3) #endregion License Information (GPL v3)
using System.ComponentModel;
using System.Windows.Forms; using System.Windows.Forms;
namespace HelpersLib namespace HelpersLib
@ -31,6 +32,7 @@ public partial class TabToTreeView : UserControl
{ {
private TabControl mainTabControl; private TabControl mainTabControl;
[Browsable(false)]
public TabControl MainTabControl public TabControl MainTabControl
{ {
get get
@ -78,12 +80,18 @@ public TabToTreeView()
TreeViewSize = 150; TreeViewSize = 150;
} }
private void FillTreeView(TreeNodeCollection nodeCollection, TabControl tab) private void FillTreeView(TreeNodeCollection nodeCollection, TabControl tab, TreeNode parent = null)
{ {
if (nodeCollection != null && tab != null) if (nodeCollection != null && tab != null)
{ {
foreach (TabPage tabPage in tab.TabPages) foreach (TabPage tabPage in tab.TabPages)
{ {
if (parent != null && tabPage.Text == "{Parent}")
{
parent.Tag = tabPage;
continue;
}
TreeNode treeNode = new TreeNode(tabPage.Text); TreeNode treeNode = new TreeNode(tabPage.Text);
if (!string.IsNullOrEmpty(tabPage.ImageKey)) if (!string.IsNullOrEmpty(tabPage.ImageKey))
{ {
@ -96,7 +104,7 @@ private void FillTreeView(TreeNodeCollection nodeCollection, TabControl tab)
{ {
if (control is TabControl) if (control is TabControl)
{ {
FillTreeView(treeNode.Nodes, control as TabControl); FillTreeView(treeNode.Nodes, control as TabControl, treeNode);
break; break;
} }
} }
@ -115,9 +123,12 @@ private void tvMain_AfterSelect(object sender, TreeViewEventArgs e)
if (tabPage != null) if (tabPage != null)
{ {
tvMain.BeginUpdate();
tcMain.Visible = true; tcMain.Visible = true;
tcMain.TabPages.Clear(); tcMain.TabPages.Clear();
tcMain.TabPages.Add(tabPage); tcMain.TabPages.Add(tabPage);
tvMain.Focus();
tvMain.EndUpdate();
} }
} }
} }