Hello Rumba and welcome!
Thanks for your feedback. We do our best to make Flexible TreeView the best treeview-listview component on the market.
About your questions:
1) To accomplish that you should create a node class that will describe your files and folders.
class FileNode : Node
{
public readonly bool IsFile;
public readonly long FileSize;
public FileNode(string pText, bool pIsFile, long pFileSize)
: base(pText)
{
IsFile = pIsFile;
FileSize = pFileSize;
}
}
Then fill the treeview by files and folders nodes:
FileNode node;
foreach (string dir in Directory.GetDirectories("c:\"))
{
node = new FileNode(dir, false, 0);
LoadDirectoryStructure(dir, node);
}
void LoadDirectoryStructure(string pDir, FileNode pParentNode)
{
FileNode node;
foreach (string dir in Directory.GetDirectories(pDir))
{
node = new FileNode(dir, false, 0);
node.AttachTo(pParentNode);
LoadDirectoryFiles(dir, node);
}
}
private void LoadDirectoryFiles(string pDir, FileNode pParentNode)
{
FileNode node;
foreach (string file in Directory.GetFiles(pDir))
{
node = new FileNode(file, true, new FileInfo(file).Length);
node.AttachTo(pParentNode);
}
}
Then attach the event handler to the treeview`s NodePostCompareAudit event:
void tree_NodePostCompareAudit(FlexibleTreeView pTreeView, Node pNode1, Node pNode2, SortOrder pSortOrder, ref eNodeCompareResult pCompareResult)
{
FileNode node1, node2;
node1 = pNode1 as FileNode;
node2 = pNode1 as FileNode;
if(node1 != null && node2 != null)
{
if(!node1.IsFile && node2.IsFile)
{
// place a folder above any file
pCompareResult = eNodeCompareResult.Higher;
}
else if(node1.IsFile && !node2.IsFile)
{
// place a file below any folder
pCompareResult = eNodeCompareResult.Lower;
}
}
}
That`s all. So main trick is the NodePostCompareAudit event handler function here.
2) About your second question: I`m happy that you choose SoftSelect feature because it`s really useful feature for cases like yours.
So to do that:
a) Extend the FileNode class stated above (add the Description property and change the ctor):
public readonly string Description;
public FileNode(string pText, bool pIsFile, long pFileSize, string pDescription)
: base(pText)
{
IsFile = pIsFile;
FileSize = pFileSize;
Description = pDescription;
}
b) open the tree`s NodeControls designer in the Visual Studio Properties Window, add NodeExpandableTextBox node control and adjust the DataFieldName field of that node control to "Description" value. Here we bound the node class`s Description property with the node control which will show that data.
c) Everywhere where you are creating a FileNode instance pass a description for that particular node in ctor as stated above.
d) And final step is to enable SoftSelect hover style:
tree.Options.Selection.HoverStyle = eHoverStyle.SoftSelect;
That`s all. It was simple is`nt it?
If you have any questions feel free to ask it here and we`ll find a solution for you.