Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_vb_dotnet thread: Adding node to the treeview in vbnet??? Why doesnt work


Message #1 by "Gabriel Brienza" <vbnetuk@y...> on Tue, 26 Feb 2002 21:32:32
I haven't looked at the treeview control yet, but in vb6 you had to 
specify the parent node?? Maybe..prob changed too though!!

If you send the form to me I'll look at it.

> 
> I have the following tree
> Globe-Country-City-Hotel
> 
> When I rightClick on the Globe I want to add a country
> I rightClick on the Country I want to add a City and so on
> 
> I now rightclick and Get a form adding a country and I put the Following 
> code
> to add a country to the Globe(rootnode).
> 
> BUT IT DOESNT WORK!!!!
> Any suggestions.After I make it work Iwill insert this into my database.
> 
> Code:
> '//Form where the treeview is
>   Dim ofrm As frmContracts = New frmContracts() 
> 
>         Dim nd As TreeNode
>         Dim Country As TreeNode
> 
> 
>         Country = ofrm.tvwContracts.Nodes(0)  
> 
>         Dim CountryFound, CityFound, HotelFound As Boolean
>         Dim CountryNode, CityNode, HotelNode As TreeNode
> 
>         'check if the  node already exist
>         For Each nd In Country.Nodes
>             If nd.Text.ToUpper = txtAddCountry.Text.ToUpper Then
>                 CountryFound = True
>                 Exit For
>             End If
>         Next
> 
>         ' Add Country, if it's not on the control already
>         If Not CountryFound Then
>             nd = Country.Nodes.Add(txtAddCountry.Text)
>         End If
>         CountryNode = nd   

  Return to Index