Howdy, Stranger!

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

In this Discussion

TElXTree: Sorting using stFloat or stCustom: How to make it work?

Sorting by Text, DateTime and Number are working.

In the demo "Tree Demos Disk Browser" the items are not correctly sorted by the size column; the values are treated as text.

I have set SortType := stCustom, but the the ItemTreeCompareItems event is not called.

Are these bugs, or what else do I have to do?

Thanks.
Raymond

Comments

  • 4 Comments sorted by Votes Date Added
  • Posts: 0 Accepted Answer Vote Up0Vote Down
    Hi, 

    The tree's SortType property is used when there is no Header. 
    If Header is visible, then sort type is taken from corresponding header section. If you want ItemTreeCompareItems to be triggered, set column contents type to Custom.

    Best regards,
    Victor



  • This information would have been helpful in the Help file.

    'Custom' is now working. Thank you.

    However, the column of integers does not sort correctly if Integer is specified in the HeaderSection.

    Specifying the type as Float does make the sort work correctly.

    The only change I make to the program is in the HeaderSections in the IDE:

    Contents Type: Integer Does not work (random order)
    Contents Type: Float Works

    All of the data in the column is integral, as they are counts converted to strings with IntToStr(...).

    Raymond
  • Ok. Explanation: I use 
    Format('%d   ', [Count]);
    to place the data in the tree.

    This centres the numbers under the heading and keeps them aligned right.

    When setting the HeaderSection Section sort mode to Integer, the sorting function does not work with the spaces being there. When setting it to floating it works.

    Perhaps the sorting routing could Trim(...) the fields before testing.

    Raymond
Sign In or Register to comment.