TreeView (and SourceSafe)

samshiell

Member
Joined
Oct 26, 2004
Messages
10
Programming Experience
10+
Hi

I've newish to .net so forgive what's (hopefully) an easy question

I'm struggling to populate a treeview. I'm reading the data from the SourceSafe object model and can only retrieve it an item at a time so it would seem obvious to me to add the items (plus the image) as each one is retrieved, but I cannot see any way to manually add treenodes plus their heirarchical relationships

Easy in VB6 but how in .net?

I've wasted over a day on this so would really appreciate a pointer or two...

Cheers

Sam
 

samshiell

Member
Joined
Oct 26, 2004
Messages
10
Programming Experience
10+
Neal / all

Here's a snippet of VB6 that populates a treeview control...
------------------------------------------------------

Private Sub ExploreProject(vssProject As vssItem)

Dim vssItem As vssItem '' a SourceSafe item - project or file
Dim xNode As Node

' Only list SourceSafe projects in the treeview... not interested in individual files

If vssProject.Type = VSSITEM_PROJECT Then

For Each vssItem In vssProject.Items(False)

Set xNode = TreeView1.Nodes.Add(vssProject.Spec, _
tvwChild, vssItem.Spec, vssItem.Name, "Folder")

'** vssProject.Spec is the full SourceSafe path of the item. I use it
' here as a unique key in order to tie children and parents together


'** Call myself to get sub-trees
ExploreProject vssItem

Next vssItem

End If
-------------------------------------------------------

Give me a shout if any of this doesn't make sense.

Thanks

Sam
 

samshiell

Member
Joined
Oct 26, 2004
Messages
10
Programming Experience
10+
Sorted...

Hi

OK I've finally got it sorted....

I realise that I probably can't populate the complete tree in one go, so I just populate the top-level, then when a user clicks on a node I go to my database and get the child values and then create all the child nodes.

Only downside with this approach is that none of the nodes have a "+" sign so you don't know if there is children until you click....

Sam
 
Top Bottom