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 ActiveX Control
View previous topic :: View next topic  
Author Message
Support



Joined: 18 Jul 2005
Posts: 731

Posted: Sat Oct 20, 2007 3:17 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 :

[VB]
Private Sub FileView1_OnBeforeColumnSort(ByVal ColumnName As String, ByVal ColumnIndex As Long, SortMethod As FileViewControl.FIVSortMethods)
' Specify custom sorting
SortMethod = FIVCustomSorting
End Sub

Private Sub FileView1_OnCompareItems(ByVal Item1 As FileViewControl.IListItem, ByVal Item2 As FileViewControl.IListItem, Comparison As Long)
' Set Comparison to indicate sort order; Item1 and Item2 specify the items being compared
' This example sorts items by the length of their displayname.
Comparison = Len(Item1.DisplayName) - Len(Item2.DisplayName)
End Sub



[MFC/C++]
void CBehaviorControlDlg::OnOnBeforeColumnSortFilevw(LPCTSTR ColumnName, long ColumnIndex, long FAR* SortMethod)
{
// Specify custom sorting
*SortMethod = 3;
}


void CBehaviorControlDlg::OnOnCompareItemsFilevw(LPDISPATCH Item1, LPDISPATCH Item2, long FAR* Comparison)
{
CListItem i1;
i1.AttachDispatch(Item1,FALSE);

CListItem i2;
i2.AttachDispatch(Item2,FALSE);

// Set Comparison to indicate sort order; Item1 and Item2 specify the items being compared
// This example sorts items by the length of their displayname.
*Comparison = i1.GetDisplayName().GetLength() - i2.GetDisplayName().GetLength();

}
Back to top
Display posts from previous:   
Forum Index -> FileView ActiveX Control All times are GMT
Page 1 of 1

 
Jump to:  


Powered by phpBB © 2001, 2005 phpBB Group