Question concerning TreeView / Expand Nodes
Messages   Related Types
This message was discovered on ASPFriends.com 'aspngwebcontrols' list.


MacWeb@gmx.de
Hi,

i got the following question:

I am using TreeView to display all departments and employees of our company.
When an employee logs on to our intranet, the tree should expand exactly to
the employees node and select it automatically.

Example for employee Markus:

- Company Name
+Department 1
+Department 2
-Department 3
- Markus <-- selected node
+Department 4
....

the only way i see to solve this problem is to use the
GetNodeFromIndex("0.2.0") Method and recursively set the expanded properties of the parent nodes
to "true".

But is there a more elegant solution for the above mentioned problem?

greetinx from germany

markus

--
GMX - Die Kommunikationsplattform im Internet.
http://www.gmx.net

Reply to this message...
 
    
Rene- Frederic Plain
SGkgLCANCiANCkkgdGhpbmsgSSBjb3VsZCBub3QgaGVscCB5b3UgYWJvdXQgdGhpcyBwcm9ibGVt
IGJ1dCBJIGhhdmUgYSBxdWVzdGlvbiBmb3IgeW91IDoNCkhvdyBkbyB5b3UgcmV0cmlldmUgdGhl
IGlkIG9mIHRoZSBlbXBsb3llZSBvZiB5b3VyIHRyZWV2aWV3ICwgSSB0cmllZCB0byBkbyB0aGUg
c2FtZSB0aGluZyB5b3UgZG8gYnV0IHRoZSBvbmx5IHR3byBkYXRhIEkgd2FzIGFibGUgdG8gcmV0
cmlldmUgd2FzIHRoZSBuYW1lIHByb3BldHkgYW5kIHRoZSBub2RlIGluZGV4IHByb3BlcnR5Li4u
LiBOb3Qgc28gZ29vZCB0byBwYXNzIGFuIGlkIHRvIGFub3RoZXIgcGFnZSBvciBhbm90aGVyIHN0
YXRlICwgIFJpZ2h0ID8NClRoYW5rIHlvdSAuDQpGcmVkIA0KDQoJLS0tLS1PcmlnaW5hbCBNZXNz
YWdlLS0tLS0gDQoJRnJvbTogTWFjV2ViQGdteC5kZSBbbWFpbHRvOk1hY1dlYkBnbXguZGVdIA0K
CVNlbnQ6IFRodSA1LzIvMjAwMiAxMDo0OSBBTSANCglUbzogYXNwbmd3ZWJjb250cm9scyANCglD
YzogDQoJU3ViamVjdDogW2FzcG5nd2ViY29udHJvbHNdIFF1ZXN0aW9uIGNvbmNlcm5pbmcgVHJl
ZVZpZXcgLyBFeHBhbmQgTm9kZXMNCgkNCgkNCgkgDQoNCg=
Reply to this message...
 
    
Shannon Cornish
Hi markus

    You could do something like this

        TreeNode selectedNode =3D
myTreeView.GetNodeFromIndex("0.2.0");

        foreach(TreeNode node in myTreeView.Nodes) {
            if (node.Nodes.Contains(selectedNode) || (node
=3D=3D selectedNode)) {
                node.Expanded =3D true;
            }
        }

    It will loop all the nodes in the collection, checking to see if
it contains the 'selectedNode' if it does, or if it is the selected
node, it will make it expanded.

More elegant, faster? I guess that's up to you to decide. :)

Shannon,

-----Original Message-----
From: Click here to reveal e-mail address [mailto:Click here to reveal e-mail address]=20
Sent: Thursday, 2 May 2002 6:49 PM
To: aspngwebcontrols
Subject: [aspngwebcontrols] Question concerning TreeView / Expand Nodes

Hi,=20

i got the following question:

I am using TreeView to display all departments and employees of our
company. When an employee logs on to our intranet, the tree should
expand exactly to the employees node and select it automatically.

Example for employee Markus:

- Company Name
+Department 1
+Department 2
-Department 3
- Markus <-- selected node
+Department 4
....

the only way i see to solve this problem is to use the
GetNodeFromIndex("0.2.0") Method and recursively set the expanded
properties of the parent nodes to "true".=20

But is there a more elegant solution for the above mentioned problem?

greetinx from germany

markus

--=20
GMX - Die Kommunikationsplattform im Internet. http://www.gmx.net

| [aspngwebcontrols] member Click here to reveal e-mail address =3D YOUR ID=20
| http://www.asplists.com/asplists/aspngwebcontrols.asp =3D JOIN/QUIT

Reply to this message...
 
    
Mike Renaud
Hi Fred,

I typically build my treeviews dynamically, and I store information (like
employee id) about a given node in it's NodeData property which can accessed
when that node is selected. You can even store XML in the NodeData
property.

hth,
Mike

----- Original Message -----
From: "Rene- Frederic Plain" <Click here to reveal e-mail address>
To: "aspngwebcontrols" <Click here to reveal e-mail address>
Sent: Thursday, May 02, 2002 10:09 AM
Subject: [aspngwebcontrols] RE: Question concerning TreeView / Expand Nodes

[Original message clipped]

the name propety and the node index property.... Not so good to pass an id
to another page or another state , Right ?
[Original message clipped]

----------------------------------------------------------------------------
----

[Original message clipped]

Reply to this message...
 
 
System.Windows.Forms.TreeNode
System.Windows.Forms.TreeView




Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
 
 Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us - Terms of Use - Privacy Policy - www.dotnet247.com