TreeView...Simple Solution Possible? 
Author Message
 TreeView...Simple Solution Possible?

Hi,,,I was wondering if there is a so called "simple" "easy"
treeview....What I am trying to say is...Is there a simple way to code the
stuff in it?

If so could someone help me?

Like I want it to look like this...

Home
- Web Pages
   My page
   Your page

Can that be done simply? (BTW once I figure it out...I will know how to do
the rest... I used the web page stuff because I couldn't think of anything
else..Thanks!



Wed, 20 Sep 2000 03:00:00 GMT  
 TreeView...Simple Solution Possible?

Hope this is straightforward enough.....it semonstrates adding the root, 2 child nodes, 2
nodes under each child, and another uner the last child.  It aslo shows using both strings
hard coded and as variables as the keys.

In general, the Add method uses this syntax:

nodX = TreeView1.Nodes.Add(parent's key name, _
                                            relationship constant ie tvwChild, _
                                            this key's keyname, _
                                            this items caption, _
                                            index to icon when, _
                                            index to icon if selected)

To add an item, you specify the parent key, the relationship, the key for this item if it
is going to have sub-items (because this becomes the patent key for those sub-items),
obviously the text to display, and optionally the icon indexes corresponding to an
imagelist on the form containing 16x16 images. A new "root" item has no parent, so commas
delimit the unneeded data.

Undoubtedly, the hardest thing is to create unique keynames for each item added.  Below,
in this simple example, I've hard-coded the values.  But realistically, you will want to
vreate those on-the-fly, using a counter.  Note however that a key must contain at least 1
thext charcter...numbers alone are not enough, and will generate and error.

Private Sub Command2_Click()

  Dim nodX As Node
  Dim cText, cKey, spkey1, mpkey, TreeName, pKey

  TreeView1.Nodes.Clear

   'create the text for the root tree item & expand the root node
   TreeName = "Web pages"
   pKey = "root"
   Set nodX = TreeView1.Nodes.Add(, , pKey, TreeName, 1, 1)
   nodX.Expanded = True

   '-----------------
   'add children as a sibling of parent "Web pages"
   cText = "My Pages"
   cKey = "key1"
   Set nodX = TreeView1.Nodes.Add(pKey, tvwChild, cKey, cText, 1, 1)
   nodX.Expanded = True

   cText = "Your Pages"
   cKey = "key2"
   Set nodX = TreeView1.Nodes.Add(pKey, tvwChild, cKey, cText, 1, 1)
   nodX.Expanded = True

   '-----------------
   'add some children under "My Pages"
   cText = "My Page's Home page"
   mpkey = "mpkey1"
   Set nodX = TreeView1.Nodes.Add("key1", tvwChild, mpkey, cText, 1, 1)
   nodX.Expanded = True

   cText = "My Page's Search page"
   mpkey = "mpkey2"
   Set nodX = TreeView1.Nodes.Add("key1", tvwChild, mpkey, cText, 1, 1)
   nodX.Expanded = True

   'add some children under "Search page"
   cText = "My Page's Search Results Form"
   spkey1 = "spkey1"
   Set nodX = TreeView1.Nodes.Add("mpkey2", tvwChild, spkey1, cText, 1, 1)
   nodX.Expanded = True

   '-----------------
   'add some children under "My Pages"
   cText = "Your Page's Home page"
   mpkey = "ypkey1"
   Set nodX = TreeView1.Nodes.Add("key2", tvwChild, mpkey, cText, 1, 1)
   nodX.Expanded = True

   cText = "Your Page's Search page"
   mpkey = "ypkey2"
   Set nodX = TreeView1.Nodes.Add("key2", tvwChild, mpkey, cText, 1, 1)
   nodX.Expanded = True

   'add some children under "Search page"
   cText = "Your Page's Search Results Form"
   spkey1 = "yspkey1"
   Set nodX = TreeView1.Nodes.Add("ypkey2", tvwChild, spkey1, cText, 1, 1)
   nodX.Expanded = True

End Sub

--
Randy Birch, MVP Visual Basic
VBnet, The Visual Basic Developers Resource Centre
http://home.sprynet.com/sprynet/rasanen/vbnet/default.htm

Common Controls Replacement Project
http://www.mvps.org/ccrp

:Hi,,,I was wondering if there is a so called "simple" "easy"
:treeview....What I am trying to say is...Is there a simple way to code the
:stuff in it?
:
:If so could someone help me?
:
:Like I want it to look like this...
:
:Home
:- Web Pages
:   My page
:   Your page
:
:
:Can that be done simply? (BTW once I figure it out...I will know how to do
:the rest... I used the web page stuff because I couldn't think of anything
:else..Thanks!
:
:



Thu, 21 Sep 2000 04:00:00 GMT  
 TreeView...Simple Solution Possible?

Thanks,,,,I will give it a try  :)

Quote:

>Hope this is straightforward enough.....it semonstrates adding the root, 2
child nodes, 2
>nodes under each child, and another uner the last child.  It aslo shows
using both strings
>hard coded and as variables as the keys.

>In general, the Add method uses this syntax:

>nodX = TreeView1.Nodes.Add(parent's key name, _
>                                            relationship constant ie
tvwChild, _
>                                            this key's keyname, _
>                                            this items caption, _
>                                            index to icon when, _
>                                            index to icon if selected)

>To add an item, you specify the parent key, the relationship, the key for
this item if it
>is going to have sub-items (because this becomes the patent key for those
sub-items),
>obviously the text to display, and optionally the icon indexes
corresponding to an
>imagelist on the form containing 16x16 images. A new "root" item has no
parent, so commas
>delimit the unneeded data.

>Undoubtedly, the hardest thing is to create unique keynames for each item
added.  Below,
>in this simple example, I've hard-coded the values.  But realistically, you
will want to
>vreate those on-the-fly, using a counter.  Note however that a key must
contain at least 1
>thext charcter...numbers alone are not enough, and will generate and error.

>Private Sub Command2_Click()

>  Dim nodX As Node
>  Dim cText, cKey, spkey1, mpkey, TreeName, pKey

>  TreeView1.Nodes.Clear

>   'create the text for the root tree item & expand the root node
>   TreeName = "Web pages"
>   pKey = "root"
>   Set nodX = TreeView1.Nodes.Add(, , pKey, TreeName, 1, 1)
>   nodX.Expanded = True

>   '-----------------
>   'add children as a sibling of parent "Web pages"
>   cText = "My Pages"
>   cKey = "key1"
>   Set nodX = TreeView1.Nodes.Add(pKey, tvwChild, cKey, cText, 1, 1)
>   nodX.Expanded = True

>   cText = "Your Pages"
>   cKey = "key2"
>   Set nodX = TreeView1.Nodes.Add(pKey, tvwChild, cKey, cText, 1, 1)
>   nodX.Expanded = True

>   '-----------------
>   'add some children under "My Pages"
>   cText = "My Page's Home page"
>   mpkey = "mpkey1"
>   Set nodX = TreeView1.Nodes.Add("key1", tvwChild, mpkey, cText, 1, 1)
>   nodX.Expanded = True

>   cText = "My Page's Search page"
>   mpkey = "mpkey2"
>   Set nodX = TreeView1.Nodes.Add("key1", tvwChild, mpkey, cText, 1, 1)
>   nodX.Expanded = True

>   'add some children under "Search page"
>   cText = "My Page's Search Results Form"
>   spkey1 = "spkey1"
>   Set nodX = TreeView1.Nodes.Add("mpkey2", tvwChild, spkey1, cText, 1, 1)
>   nodX.Expanded = True

>   '-----------------
>   'add some children under "My Pages"
>   cText = "Your Page's Home page"
>   mpkey = "ypkey1"
>   Set nodX = TreeView1.Nodes.Add("key2", tvwChild, mpkey, cText, 1, 1)
>   nodX.Expanded = True

>   cText = "Your Page's Search page"
>   mpkey = "ypkey2"
>   Set nodX = TreeView1.Nodes.Add("key2", tvwChild, mpkey, cText, 1, 1)
>   nodX.Expanded = True

>   'add some children under "Search page"
>   cText = "Your Page's Search Results Form"
>   spkey1 = "yspkey1"
>   Set nodX = TreeView1.Nodes.Add("ypkey2", tvwChild, spkey1, cText, 1, 1)
>   nodX.Expanded = True

>End Sub

>--
>Randy Birch, MVP Visual Basic
>VBnet, The Visual Basic Developers Resource Centre
>http://home.sprynet.com/sprynet/rasanen/vbnet/default.htm

>Common Controls Replacement Project
>http://www.mvps.org/ccrp


>:Hi,,,I was wondering if there is a so called "simple" "easy"
>:treeview....What I am trying to say is...Is there a simple way to code the
>:stuff in it?
>:
>:If so could someone help me?
>:
>:Like I want it to look like this...
>:
>:Home
>:- Web Pages
>:   My page
>:   Your page
>:
>:
>:Can that be done simply? (BTW once I figure it out...I will know how to do
>:the rest... I used the web page stuff because I couldn't think of anything
>:else..Thanks!
>:
>:



Thu, 21 Sep 2000 04:00:00 GMT  
 TreeView...Simple Solution Possible?

I am just wrapping up a project called SimpleTree.  If you would like to
beta it for me I'll send you a copy when I finish it.

Patrick

Quote:

> Hi,,,I was wondering if there is a so called "simple" "easy"
> treeview....What I am trying to say is...Is there a simple way to code the
> stuff in it?

> If so could someone help me?

> Like I want it to look like this...

> Home
> - Web Pages
>    My page
>    Your page

> Can that be done simply? (BTW once I figure it out...I will know how to do
> the rest... I used the web page stuff because I couldn't think of anything
> else..Thanks!



Sun, 24 Sep 2000 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Search List Box - Possible Solution

2. Search List Box - Possible Solution

3. OLE Automation Errors - Possible Solution

4. MultiSelect HTML Tables Possible Solution = Bookmarks?

5. Simple solution VB4

6. looking for a more elegant solution to simple problem

7. A Simple SOLUTION for your Microsoft Bugs!!!

8. TreeView nodes clear method - SOLUTION

9. TreeView.Nodes.Clear is slooooowww (Solution Within!)

10. Newbie: Is it possible, is it simple?

11. deploying simple vb app possible?

12. simple mail hyperlink in VB possible?

 

 
Powered by phpBB® Forum Software