Menu
Home
Forums
New posts
Search forums
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
C# Community
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Home
Forums
VB.NET
Windows Forms
Problem converting vb6 Treeview code to vb.Net
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="randerson" data-source="post: 11297" data-attributes="member: 3406"><p>I ported a VB6 application to VB .Net 2003 and I am having a problem loading a TreeView control correctly. This code worked fine in VB6 but the functionality of the Treeview.Nodes.Add function has changed. Basically, this application allows a user to extract check-out information and check-in comments from a SourceSafe DB. I load the Treeview control with a list of the SourceSafe Projects in the identified SourceSafe DB.</p><p></p><p>The sub I use to fill the Treeview control is called recursively. Here is the code for I am using.</p><p>[CODE]</p><p>Public Sub PopulateVSSTree(ByRef tvwControl As TreeView, ByVal intParentNode As Integer, ByRef objVSSDatabase As SourceSafeTypeLib.VSSDatabase, Optional ByVal szProjectRoot As String = "$/", Optional ByVal bIncludeFiles As Boolean = True)</p><p></p><p> Static iTreeLevel As Short</p><p> Dim objVSSItem As SourceSafeTypeLib.VSSItem</p><p> Dim tvwNode As TreeNode</p><p> Dim strNodeName As String</p><p></p><p> On Error GoTo Err_handler</p><p></p><p> If iTreeLevel = 0 Then</p><p> SmartClearNodes(tvwControl)</p><p> strNodeName = szProjectRoot.ToString()</p><p> tvwNode = New TreeNode(strNodeName)</p><p> tvwControl.Nodes.Add(tvwNode)</p><p> End If</p><p></p><p> iTreeLevel = iTreeLevel + 1</p><p> If objVSSDatabase.VSSItem(szProjectRoot).Type = SourceSafeTypeLib.VSSItemType.VSSITEM_PROJECT Then</p><p> For Each objVSSItem In objVSSDatabase.VSSItem(szProjectRoot).Items()</p><p> If objVSSItem.Type = SourceSafeTypeLib.VSSItemType.VSSITEM_PROJECT Then</p><p> strNodeName = objVSSItem.Name</p><p> tvwNode = New TreeNode(strNodeName)</p><p> tvwControl.Nodes(intParentNode).Nodes.Add(tvwNode)</p><p> PopulateVSSTree(tvwControl, tvwNode.Index(), objVSSDatabase, szProjectRoot & objVSSItem.Name.ToString & "/", bIncludeFiles)</p><p> Else</p><p> If bIncludeFiles Then</p><p> strNodeName = objVSSItem.Name</p><p> tvwNode = New TreeNode(strNodeName)</p><p> tvwControl.Nodes(intParentNode).Nodes.Add(tvwNode)</p><p> End If</p><p> End If</p><p> Next objVSSItem</p><p> End If</p><p></p><p>Exit_Sub:</p><p> iTreeLevel = iTreeLevel - 1</p><p> Exit Sub</p><p></p><p>Err_handler:</p><p> iTreeLevel = 0</p><p> Err.Raise(Err.Number, Err.Source, Err.Description)</p><p>End Sub</p><p>[/CODE]</p><p></p><p>First I realize the error handling section needs to be corrected using the .Net Try..Except..Finally method but that isn't my immediate problem. My problem is when I recursively call the sub, how do I identify the parent node to which I should add this child node. In VB6 the Node.Add function let me pass in a relative reference (parent key), the relationship type (Child), key for the new node, and the node text. In the .Net version it is basically Node.Add (node text) so somehow I need to point the node to the nodes parent. I was trying this by passing in the Node.Index of the node I just created but that doesn’t work. </p><p>What I should get is the following</p><p>[CODE] </p><p>$/ </p><p>- MXT</p><p> AFCEE _Access</p><p> - AFCEE Data Gathering</p><p> Database</p><p> Documentation</p><p> - Final Report</p><p> Final Documentation</p><p> FinalizedProcesses</p><p> - CCB</p><p> PMR</p><p>....</p><p>Etc, etc.</p><p>[/CODE] </p><p>What I actually get is the following</p><p>[CODE] </p><p>$/</p><p> MXT</p><p> AFCEE _Access</p><p> AFCEE Data Gathering</p><p>[/CODE] </p><p></p><p>And that’s it. As you can see, AFCEE_Access and AFCEE Data Gathering are not children to MXT and also there aren’t any other children.</p><p></p><p>Can anyone suggest a solution to my problem?</p><p></p><p>Thanks</p><p>Richard Anderson</p></blockquote><p></p>
[QUOTE="randerson, post: 11297, member: 3406"] I ported a VB6 application to VB .Net 2003 and I am having a problem loading a TreeView control correctly. This code worked fine in VB6 but the functionality of the Treeview.Nodes.Add function has changed. Basically, this application allows a user to extract check-out information and check-in comments from a SourceSafe DB. I load the Treeview control with a list of the SourceSafe Projects in the identified SourceSafe DB. The sub I use to fill the Treeview control is called recursively. Here is the code for I am using. [CODE] Public Sub PopulateVSSTree(ByRef tvwControl As TreeView, ByVal intParentNode As Integer, ByRef objVSSDatabase As SourceSafeTypeLib.VSSDatabase, Optional ByVal szProjectRoot As String = "$/", Optional ByVal bIncludeFiles As Boolean = True) Static iTreeLevel As Short Dim objVSSItem As SourceSafeTypeLib.VSSItem Dim tvwNode As TreeNode Dim strNodeName As String On Error GoTo Err_handler If iTreeLevel = 0 Then SmartClearNodes(tvwControl) strNodeName = szProjectRoot.ToString() tvwNode = New TreeNode(strNodeName) tvwControl.Nodes.Add(tvwNode) End If iTreeLevel = iTreeLevel + 1 If objVSSDatabase.VSSItem(szProjectRoot).Type = SourceSafeTypeLib.VSSItemType.VSSITEM_PROJECT Then For Each objVSSItem In objVSSDatabase.VSSItem(szProjectRoot).Items() If objVSSItem.Type = SourceSafeTypeLib.VSSItemType.VSSITEM_PROJECT Then strNodeName = objVSSItem.Name tvwNode = New TreeNode(strNodeName) tvwControl.Nodes(intParentNode).Nodes.Add(tvwNode) PopulateVSSTree(tvwControl, tvwNode.Index(), objVSSDatabase, szProjectRoot & objVSSItem.Name.ToString & "/", bIncludeFiles) Else If bIncludeFiles Then strNodeName = objVSSItem.Name tvwNode = New TreeNode(strNodeName) tvwControl.Nodes(intParentNode).Nodes.Add(tvwNode) End If End If Next objVSSItem End If Exit_Sub: iTreeLevel = iTreeLevel - 1 Exit Sub Err_handler: iTreeLevel = 0 Err.Raise(Err.Number, Err.Source, Err.Description) End Sub [/CODE] First I realize the error handling section needs to be corrected using the .Net Try..Except..Finally method but that isn't my immediate problem. My problem is when I recursively call the sub, how do I identify the parent node to which I should add this child node. In VB6 the Node.Add function let me pass in a relative reference (parent key), the relationship type (Child), key for the new node, and the node text. In the .Net version it is basically Node.Add (node text) so somehow I need to point the node to the nodes parent. I was trying this by passing in the Node.Index of the node I just created but that doesn’t work. What I should get is the following [CODE] $/ - MXT AFCEE _Access - AFCEE Data Gathering Database Documentation - Final Report Final Documentation FinalizedProcesses - CCB PMR .... Etc, etc. [/CODE] What I actually get is the following [CODE] $/ MXT AFCEE _Access AFCEE Data Gathering [/CODE] And that’s it. As you can see, AFCEE_Access and AFCEE Data Gathering are not children to MXT and also there aren’t any other children. Can anyone suggest a solution to my problem? Thanks Richard Anderson [/QUOTE]
Insert quotes…
Verification
Post reply
Home
Forums
VB.NET
Windows Forms
Problem converting vb6 Treeview code to vb.Net
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.
Accept
Learn more…
Top
Bottom