Skip to content

Commit 637996d

Browse files
author
Kevin Grech (Exigy)
committed
Add default sort (Ascending only at the moment)
1 parent 724975a commit 637996d

3 files changed

Lines changed: 34 additions & 0 deletions

File tree

src/lib/MsDyn.Contrib.CloneFieldDefinitions/CloneFieldsControl.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,10 @@ private void ListView1_ColumnClick(object sender, ColumnClickEventArgs e)
438438

439439
listView1.Invalidate();
440440
}
441+
else
442+
{
443+
listView1.ListViewItemSorter = new ListViewItemComparer(e.Column);
444+
}
441445
}
442446

443447
private string GetDisplayLabel(Microsoft.Xrm.Sdk.Label label)
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using System;
2+
using System.Collections;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
using System.Windows.Forms;
8+
9+
namespace MsDyn.Contrib.CloneFieldDefinitions
10+
{
11+
class ListViewItemComparer: IComparer
12+
{
13+
private int col;
14+
public ListViewItemComparer()
15+
{
16+
col = 0;
17+
}
18+
19+
public ListViewItemComparer(int column)
20+
{
21+
col = column;
22+
}
23+
24+
public int Compare(object x, object y)
25+
{
26+
return String.Compare(((ListViewItem)x).SubItems[col].Text, ((ListViewItem)y).SubItems[col].Text);
27+
}
28+
}
29+
}

src/lib/MsDyn.Contrib.CloneFieldDefinitions/MsDyn.Contrib.CloneFieldDefinitions.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@
113113
<Compile Include="CloneFieldsControl.cs">
114114
<SubType>UserControl</SubType>
115115
</Compile>
116+
<Compile Include="ListViewItemComparer.cs" />
116117
<Compile Include="Properties\AssemblyInfo.cs" />
117118
<Compile Include="StringExtensions.cs" />
118119
</ItemGroup>

0 commit comments

Comments
 (0)