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)
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

View file

@ -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;

View file

@ -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();
}
}
}