Frequently Asked Component Specific Questions
Options |
Display all FAQ items |
Displaying items 1 to 1 of 1, page 1 of 1
<< previous next >>
TMS FMX UI Pack
TTMSFMXDirectoryTreeView: How to display folders first followed by files as in File Explorer
TTMSFMXDirectoryTreeView: How to display folders first followed by files as in File Explorer
You could accomplish this by using the following code.
procedure TForm1.FormCreate(Sender: TObject); begin TMSFMXDirectoryTreeView1.Filter := ''''; TMSFMXDirectoryTreeView1.LoadDirectory(''E:\''); TMSFMXDirectoryTreeView1.Sort(0, True, True, nsmDescending); end; procedure TForm1.TMSFMXDirectoryTreeView1AfterExpandNode(Sender: TObject; ANode: TTMSFMXTreeViewVirtualNode); begin TMSFMXDirectoryTreeView1.Sort(0, True, True, nsmDescending); end; procedure TForm1.TMSFMXDirectoryTreeView1NodeCompare(Sender: TObject; Node1, Node2: TTMSFMXTreeViewNode; AColumn: Integer; var ACompareResult: Integer); var n1: TTMSFMXDirectoryTreeViewNode; n2: TTMSFMXDirectoryTreeViewNode; begin n1 := TTMSFMXDirectoryTreeViewNode(Node1); n2 := TTMSFMXDirectoryTreeViewNode(Node2); ACompareResult := AnsiCompareStr(ExtractFileExt(n1.FileName), ExtractFileExt(n2.FileName)); if ACompareResult = 0 then ACompareResult := AnsiCompareStr(n1.StrippedHTMLText[AColumn], n2.StrippedHTMLText[AColumn]); ACompareResult := ACompareResult * -1; end;