int SortByColumn = -1; //
int SortOrder = 1; //
void __fastcall TForm1::ListView1ColumnClick(TObject *Sender, TListColumn *Column)
{
if(SortByColumn == Column->Index) SortOrder *= -1; //
else SortOrder = 1; //
ListView1->CustomSort(NULL, Column->Index);
SortByColumn = Column->Index; //
}
void __fastcall TForm1::ListView1Compare(TObject *Sender, TListItem *Item1,
TListItem *Item2, int Data, int &Compare)
{
if(Data == 0)
{
if(Item1->Caption < Item2->Caption) Compare = -1;
else if(Item1->Caption > Item2->Caption) Compare = 1;
else Compare = 0;
}
else
{
if(Item1->SubItems->Strings[Data-1] < Item2->SubItems->Strings[Data-1]) Compare = -1;
else if(Item1->SubItems->Strings[Data-1] > Item2->SubItems->Strings[Data-1]) Compare = 1;
else Compare = 0;
}
Compare *= SortOrder; //
}
'Work' 카테고리의 다른 글
| Visual Studio의 fflush 이야기 (1) | 2007/11/20 |
|---|---|
| TimeAttack (0) | 2007/03/29 |
| Buffering Error (0) | 2006/05/18 |
| Builder Listview Column Sorting (0) | 2006/03/31 |
| Variant Conversion (0) | 2006/03/31 |
| "extern C"에 대하여 (0) | 2006/03/30 |