mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-01 17:56:51 +13:00
now history list is sortable by clicking column headers
This commit is contained in:
parent
98eca3c2ec
commit
7f7f93794e
3 changed files with 31 additions and 1 deletions
2
HistoryLib/HistoryForm.Designer.cs
generated
2
HistoryLib/HistoryForm.Designer.cs
generated
|
@ -267,7 +267,6 @@ private void InitializeComponent()
|
|||
this.chHost,
|
||||
this.chURL});
|
||||
this.lvHistory.FullRowSelect = true;
|
||||
this.lvHistory.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable;
|
||||
this.lvHistory.HideSelection = false;
|
||||
this.lvHistory.Location = new System.Drawing.Point(8, 288);
|
||||
this.lvHistory.Name = "lvHistory";
|
||||
|
@ -275,6 +274,7 @@ private void InitializeComponent()
|
|||
this.lvHistory.TabIndex = 1;
|
||||
this.lvHistory.UseCompatibleStateImageBehavior = false;
|
||||
this.lvHistory.View = System.Windows.Forms.View.Details;
|
||||
this.lvHistory.ColumnClick += new System.Windows.Forms.ColumnClickEventHandler(this.lvHistory_ColumnClick);
|
||||
this.lvHistory.ItemSelectionChanged += new System.Windows.Forms.ListViewItemSelectionChangedEventHandler(this.lvHistory_ItemSelectionChanged);
|
||||
this.lvHistory.KeyDown += new System.Windows.Forms.KeyEventHandler(this.lvHistory_KeyDown);
|
||||
this.lvHistory.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.lvHistory_MouseDoubleClick);
|
||||
|
|
|
@ -25,6 +25,7 @@ You should have received a copy of the GNU General Public License
|
|||
|
||||
using HelpersLib;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
|
@ -325,6 +326,30 @@ private void lvHistory_KeyDown(object sender, KeyEventArgs e)
|
|||
e.Handled = true;
|
||||
}
|
||||
|
||||
private void lvHistory_ColumnClick(object sender, ColumnClickEventArgs e)
|
||||
{
|
||||
this.lvHistory.ListViewItemSorter = new ListViewItemComparer(e.Column);
|
||||
lvHistory.Sort();
|
||||
}
|
||||
|
||||
#endregion Form events
|
||||
|
||||
}
|
||||
|
||||
class ListViewItemComparer : IComparer
|
||||
{
|
||||
private int col;
|
||||
public ListViewItemComparer()
|
||||
{
|
||||
col = 0;
|
||||
}
|
||||
public ListViewItemComparer(int column)
|
||||
{
|
||||
col = column;
|
||||
}
|
||||
public int Compare(object x, object y)
|
||||
{
|
||||
return String.Compare(((ListViewItem)x).SubItems[col].Text, ((ListViewItem)y).SubItems[col].Text);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -96,6 +96,11 @@
|
|||
<Name>HelpersLib</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="HistoryForm.resx">
|
||||
<DependentUpon>HistoryForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>
|
||||
|
|
Loading…
Reference in a new issue