Sorting TListView by Column Click

I'm new to VCL feild and i need a way to sort a TListView when Column Click.
All resources on the net are in Delphi, and I'm not programmer of Delphi or Pascal, However i read these source codes and i understand some of them but i don't know how to call the function since i don't understand What to pass to the function.
Here is one source code which you can get by serching any site talk about delphi builder
please make it detailed as possible.

small programmer,


  • Hello M-Nasim,

    I translated the code to C++ Builder below, without knowing what a TListView object does. The code below compiles, but because I do not know HOW the TListView works, I don't know if it works correct (but I guess it does).

    void __fastcall TForm1::ListView1Compare(
    TObject *Sender, //The caller of this command, most often Form1
    TListItem *Item1, // ?
    TListItem *Item2, // ?
    int Data, // ?
    int &Compare) // ? (Note that Compare is passed by reference,
    // therefore changing its value below, changes
    // something important
    const int intItem1 = StrToInt(Item1->Caption); //Convert String to integers
    const int intItem2 = StrToInt(Item2->Caption);
    if (intItem1 < intItem2)
    Compare = -1;
    if (intItem1 > intItem2)
    Compare = 1;
    else // intItem1 = intItem2
    Compare = 0;


    Good luck and have fun,

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


In this Discussion