哪里有TreeView和ListView的资料啊,或者小例子!
谢谢啊!
我在网上找了一个。但看不懂
帮帮我啊
private void EnumDrives(TreeNode ParentNode)
{
if(ParentNode.Nodes.Count==0)
{
foreach(string drive in Directory.GetLogicalDrives())
{
FolderTree.SelectedNode=ParentNode;
TreeNode TempNode=new TreeNode();
TempNode.Text=drive.Substring(0,drive.Length-1);
TempNode.Tag=drive;
TempNode.ImageIndex=1;
TempNode.SelectedImageIndex=1;
FolderTree.SelectedNode.Nodes.Add(TempNode);
FolderTree.SelectedNode.Nodes[FolderTree.SelectedNode.Nodes.Count-1].EnsureVisible();
}
}
}
private void EnumDirectories(TreeNode ParentNode)
{
FolderTree.SelectedNode=ParentNode;
string DirectoryPath=ParentNode.Tag.ToString();
if(ParentNode.Nodes.Count==0)
{
if(DirectoryPath.Substring(DirectoryPath.Length-1)!=@"\")
DirectoryPath+=@"\";
try
{
foreach(string directory in Directory.GetDirectories(DirectoryPath))
{
TreeNode TempNode=new TreeNode();
TempNode.Text=directory.Substring(directory.LastIndexOf(@"\")+1);
TempNode.Tag=directory;
TempNode.ImageIndex=3;
TempNode.SelectedImageIndex=2;
FolderTree.SelectedNode.Nodes.Add(TempNode);
FolderTree.SelectedNode.Nodes[FolderTree.SelectedNode.Nodes.Count-1].EnsureVisible();
}
}
catch(Exception)
{
}
}
}
}
}