How can I clone/copy all the nodes from one TreeView Control to another?
The following code snippet demonstrates how you can clone or copy all the nodes in TreeView1 to TreeView2 by clicking on Button1. [C#] private void IterateTreeNodes (TreeNode originalNode, TreeNode rootNode) { foreach( TreeNode childNode in originalNode.Nodes) { TreeNode newNode = new TreeNode(childNode.Text); newNode.Tag = childNode.Tag; this.treeView2.SelectedNode = rootNode; this.treeView2.SelectedNode.Nodes.Add(newNode); IterateTreeNodes(childNode, newNode); } } //Button Click code private void button1_Click(object sender, System.EventArgs e) { foreach( TreeNode originalNode in this.treeView1.Nodes) { TreeNode newNode = new TreeNode(originalNode.Text); newNode.Tag = originalNode.Tag; this.treeView2.Nodes.Add(newNode); IterateTreeNodes(originalNode, newNode); } } [VB.NET] Private Sub IterateTreeNodes(ByVal originalNode As TreeNode, ByVal rootNode As TreeNode) Dim childNode As TreeNode For Each childNode In originalNode.Nodes Dim NewNode As TreeNode = New TreeNode(childNode.Text) NewNode.Tag = childNode.Tag Me.treeView2.SelectedNode = rootNode Me.treeView2.SelectedNode.Nodes.Add(NewNode) IterateTreeNodes(childNode, NewNode) Next End Sub ’Button Click code Private Sub button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Dim originalNode As TreeNode For Each originalNode In Me.treeView1.Nodes Dim NewNode As TreeNode = New TreeNode(originalNode.Text) NewNode.Tag = originalNode.Tag Me.treeView2.Nodes.Add(NewNode) IterateTreeNodes(originalNode, NewNode) Next End Sub
How can I launch ILDASM from the VS.NET 2003 IDE?
Launch VS.NET and choose Tools->External Tools->Add and add settings as show below: Title: ILDASM (or anything else of your choice) Command: C:\Program Files\Microsoft.NET\SDK\v1.1\Bin\ildasm.exe Arguments: $(TargetPath) Initial Directory: $(TargetDir) Use Output Window: unchecked Prompt for arguments: unchecked Close on exit: checked.
How can I populate a TreeView Control with XML Data?
The following articles on MSDN give you step by step instructions on how you can populate a TreeView Control with data from an XML file. C#: Populate a TreeView Control with XML Data in Visual C# .NET VB.NET: Populate a TreeView Control with XML Data in Visual Basic .NET
How can I open a project created with Visual Studio .NET 2003 in Visual Studio .NET 2002?
Check out the following article in CodeProject : A Utility to Convert VS.NET 2003 Project Files.
How do I determine which button in a Toolbar is clicked?
When you click on a button on a Toolbar the click is sent to the Toolbar, so you need to check the ToolBarButtonClickEventArgs’s button property to determine the button on the Toolbar that was clicked. [C#] private void toolBar1_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e) { //check if toolBarButton1 was clicked if (e.Button == toolBarButton1) { MessageBox.Show('Button 1 clicked'); } } [VB.NET] Private Sub toolBar1_ButtonClick(ByVal sender As Object, ByVal e As System.Windows.Forms.ToolBarButtonClickEventArgs) ’check if toolBarButton1 was clicked If e.Button = toolBarButton1 Then MessageBox.Show('Button 1 clicked') End If End Sub