Hi Le Minh,
I'm not sure where to begin. Do you have Visual Studio.NET 2005? Are you familiar with WinForms applications and Controls? Are
you familiar with the TreeView or WebBrowser controls? Are you familiar with handling events? If you don't understand some or any
of the above questions then I'm probably not going to be able to help you short of writing the entire application, which I won't do,
but I'll try to give you some guidance.
That said, here's the general idea if you're using Visual Studio.NET (any edition, including Express):
1. Create a new Windows application project.
2. Add a WebBrowser control from the toolbox onto Form1. (You can position it however you'd like)
3. Add a TreeView control from the toolbox onto Form1. (You can position it however you'd like)
4. Set the WebBrowser.Url property to the url of your html document (this is the easiest way to load the document).
5. Create an event handler for the WebBrowser.Docu mentCompleted event. It should look like the following:
private void webBrowser1_Doc umentCompleted( object sender,
WebBrowserDocum entCompletedEve ntArgs e)
{
// make sure that the TreeView is cleared in case the browser navigates to another url
treeView1.Nodes .Clear();
// create the root node for the TreeView, which will contain all other nodes
TreeNode rootNode = treeView1.Nodes .Add("Root");
// Fill the TreeView, recursively, starting from the root node
FillTreeViewRec ursively(rootNo de, webBrowser1.Doc ument.All);
}
6. Create the FillTreeViewRec ursively method:
private void FillTreeViewRec ursively(TreeNo de currentNode, HtmlElementColl ection elements)
{
// loop through the specified collection of elements and create their respective nodes
foreach (HtmlElement element in elements)
{
// create a new node for the current element and add it under the currentNode
TreeNode node = currentNode.Nod es.Add(element. TagName);
// optional: store a reference to the element that this node represents
node.Tag = element;
// create the nodes under this node for the elements contained by the current element
FillTreeViewRec ursively(node, element.All);
}
}
Please be aware that I didn't try to build this code and so it will probably need some modifications.
--
Dave Sexton
"Le Minh" <ha*******@hotm ail.comwrote in message news:OO******** ******@TK2MSFTN GP02.phx.gbl...
can you show me the way, i 'm confuse about this. you can write a small app,
can't you ?