diff --git a/HelpersLib/UserControls/TabToListView.Designer.cs b/HelpersLib/UserControls/TabToListView.Designer.cs index d04c78922..eb29e3e5b 100644 --- a/HelpersLib/UserControls/TabToListView.Designer.cs +++ b/HelpersLib/UserControls/TabToListView.Designer.cs @@ -29,9 +29,9 @@ protected override void Dispose(bool disposing) private void InitializeComponent() { this.scMain = new System.Windows.Forms.SplitContainer(); + this.tcMain = new System.Windows.Forms.TabControl(); this.lvMain = new HelpersLib.MyListView(); this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.tcMain = new System.Windows.Forms.TabControl(); ((System.ComponentModel.ISupportInitialize)(this.scMain)).BeginInit(); this.scMain.Panel1.SuspendLayout(); this.scMain.Panel2.SuspendLayout(); @@ -59,6 +59,15 @@ private void InitializeComponent() this.scMain.SplitterWidth = 3; this.scMain.TabIndex = 0; // + // tcMain + // + this.tcMain.Dock = System.Windows.Forms.DockStyle.Fill; + this.tcMain.Location = new System.Drawing.Point(0, 0); + this.tcMain.Name = "tcMain"; + this.tcMain.SelectedIndex = 0; + this.tcMain.Size = new System.Drawing.Size(460, 500); + this.tcMain.TabIndex = 0; + // // lvMain // this.lvMain.AutoFillColumn = true; @@ -76,15 +85,7 @@ private void InitializeComponent() this.lvMain.UseCompatibleStateImageBehavior = false; this.lvMain.View = System.Windows.Forms.View.Details; this.lvMain.SelectedIndexChanged += new System.EventHandler(this.lvMain_SelectedIndexChanged); - // - // tcMain - // - this.tcMain.Dock = System.Windows.Forms.DockStyle.Fill; - this.tcMain.Location = new System.Drawing.Point(0, 0); - this.tcMain.Name = "tcMain"; - this.tcMain.SelectedIndex = 0; - this.tcMain.Size = new System.Drawing.Size(460, 500); - this.tcMain.TabIndex = 0; + this.lvMain.MouseUp += new System.Windows.Forms.MouseEventHandler(this.lvMain_MouseUp); // // TabToListView // diff --git a/HelpersLib/UserControls/TabToListView.cs b/HelpersLib/UserControls/TabToListView.cs index 2331830d0..eabf8ffb2 100644 --- a/HelpersLib/UserControls/TabToListView.cs +++ b/HelpersLib/UserControls/TabToListView.cs @@ -120,9 +120,28 @@ private void FillListView(TabControl tab) } } + private void lvMain_MouseUp(object sender, MouseEventArgs e) + { + if (lvMain.SelectedItems.Count == 0 && (e.Button == MouseButtons.Left || e.Button == MouseButtons.Right)) + { + ListViewItem lvi = lvMain.GetItemAt(e.X, e.Y); + + if (lvi == null) + { + // Workaround for 1px space between items + lvi = lvMain.GetItemAt(e.X, e.Y - 1); + } + + if (lvi != null) + { + lvi.Selected = true; + } + } + } + private void lvMain_SelectedIndexChanged(object sender, EventArgs e) { - if (lvMain.SelectedItems != null && lvMain.SelectedItems.Count > 0) + if (lvMain.SelectedItems.Count > 0) { TabPage tabPage = lvMain.SelectedItems[0].Tag as TabPage; @@ -131,6 +150,7 @@ private void lvMain_SelectedIndexChanged(object sender, EventArgs e) tcMain.Visible = true; tcMain.TabPages.Clear(); tcMain.TabPages.Add(tabPage); + lvMain.Focus(); } } }