Sky Software Homepage LogicNP Software Knowledge Base And FAQ

 
Contact Product Support    SearchSearch      Subscribe to the RSS feed for this forum

HOWTO: Implement custom sorting of items

 
Subscribe to the RSS feed for this forum  Forum Index -> FileView.Net/WPF
View previous topic :: View next topic  
Author Message
Support



Joined: 18 Jul 2005
Posts: 731

Posted: Sat Oct 20, 2007 3:10 am    Post subject: HOWTO: Implement custom sorting of items

Items can be sorted using programmer-defined custom logic. To use custom sorting, use the BeforeColumnSort and CompareItems events as follows :

[C#]
private void fileView1_BeforeColumnSort(object sender, LogicNP.FileViewControl.ColumnSortEventArgs e)
{
// Specify custom sorting
e.SortMethod=LogicNP.FileViewControl.SortMethods.CustomSorting;
}

private void fileView1_CompareItems(object sender, LogicNP.FileViewControl.CompareItemsEventArgs e)
{
// Set e.Comparison to indicate sort order; e.Item1 and e.Item2 specify the items being compared
// This example sorts items by the length of their displayname.
e.Comparison = e.Item1.DisplayName.Length - e.Item2.DisplayName.Length;
}



[VB.Net]
Private Sub FileView1_BeforeColumnSort(ByVal sender As Object, ByVal e As LogicNP.FileViewControl.ColumnSortEventArgs) Handles FileView1.BeforeColumnSort
' Specify custom sorting
e.SortMethod = LogicNP.FileViewControl.SortMethods.CustomSorting
End Sub

Private Sub FileView1_CompareItems(ByVal sender As Object, ByVal e As LogicNP.FileViewControl.CompareItemsEventArgs) Handles FileView1.CompareItems
' Set e.Comparison to indicate sort order; e.Item1 and e.Item2 specify the items being compared
' This example sorts items by the length of their displayname.
e.Comparison = e.Item1.DisplayName.Length - e.Item2.DisplayName.Length
End Sub
Back to top
Display posts from previous:   
Forum Index -> FileView.Net/WPF All times are GMT
Page 1 of 1

 
Jump to:  


Powered by phpBB © 2001, 2005 phpBB Group