Sent to Support@VisualWebGui.com ...
Attached is a sample application that contains a simple docked TreeView that scans “Program Files” and loads all files in a TreeView.
When the VS2010 devenv.exe is found that node is expanded and shown using Node.EnsureVisible.
In the WinForm version the treeview scrolls so that the node is visible.
In the Visual WebGUI version, the treeview does not scroll.
Here's the sample code for reference too...
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
string[] Files = System.IO.Directory.GetFiles("C:\\Program Files", "*.*", System.IO.SearchOption.AllDirectories);
foreach (string File in Files)
{
List<string> FileParts = new List<string>(File.Split('\\'));
AddTreeNode(treeView1.Nodes, FileParts);
}
treeView1.SelectedNode.EnsureVisible();
}
private void AddTreeNode(TreeNodeCollection Nodes, List<string> FileParts)
{
TreeNode ExistingNode = GetExistingNode(Nodes, FileParts[0]);
if (ExistingNode == null)
{
ExistingNode = new TreeNode(FileParts[0]);
Nodes.Add(ExistingNode);
}
if (FileParts.Count > 1)
{
FileParts.RemoveAt(0);
AddTreeNode(ExistingNode.Nodes, FileParts);
}
else
{
Debug.WriteLine(ExistingNode.FullPath);
if (ExistingNode.FullPath == @"C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe")
{
treeView1.SelectedNode = ExistingNode;
//while (ExistingNode != null)
//{
// ExistingNode.Expand();
// ExistingNode = ExistingNode.Parent;
//}
}
}
}
private TreeNode GetExistingNode(TreeNodeCollection Nodes, string FileName)
{
foreach (TreeNode Node in Nodes)
{
if (Node.Text == FileName)
{
return Node;
}
}
return null;
}
}