469,580 Members | 1,865 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,580 developers. It's quick & easy.

select node in treeview

Hallo!

I'm filling my treenode tv with AD-infos with the following code:
__________________________________________________ __________________
private enum AdImages
{
AdRoot,
Ou,
Container,
OpenContainer,
Computer,
User,
Group,
Unknown,
Unavailable
}
private DirectoryEntry _AdRootDSE = null;
private DirectoryEntry _AdRoot = null;

try
{
this._AdRootDSE = new DirectoryEntry(@"LDAP://rootDSE");
this._AdRoot = new DirectoryEntry("LDAP://" + (string)

this._AdRootDSE.Properties["defaultNamingContext"].Value);
TreeNode root = new TreeNode((string)this._AdRootDSE.Properties
["defaultNamingContext"].Value,
(int)AdImages.AdRoot,
(int)AdImages.AdRoot);
root.Tag = this._AdRoot;
this.tV.Nodes.Clear();
this.tV.Nodes.Add(root);
this.tV.ExpandAll();
}
catch
{
throw new Exception("Error connecting to AD");
}
__________________________________________________ __________________

Now I would like to select a single node in the treeview. I've got the info
which one stored in a string like this: "OU=Testunit,DC=Domain,DC=local".
How can I select this one? I've tried a lot of things but nothing works. Can
anyone help me please?

Thanks in advance!!!
May 8 '06 #1
4 9349
Hi Martin,

To select a node in the TreeView, you can use TreeView.SelectedNode
property to set the current selected node in the controls. It must be a
node in the TreeView's Nodes tree.

Please check the following link for more information:

http://msdn2.microsoft.com/en-us/lib...treeview.selec
tednode.aspx

Kevin Yu
Microsoft Online Community Support

================================================== ==========================
==========================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
================================================== ==========================
==========================

(This posting is provided "AS IS", with no warranties, and confers no
rights.)

May 10 '06 #2
Hallo Kevin,

thanks for your answer. I know this article, but it's no help. There is only
an example for getting the selected node.
But I need help SETTING the selected node. Code like
string val = "OU=Testunit,DC=Domain,DC=local";

this.tV.SelectedNode = val;
can't work, because val is a string not a node and I've got the info of the
node to select only in a string.

What must I change? Or do you know an other example?

Thanks for your reply!!

"Kevin Yu [MSFT]" wrote:
Hi Martin,

To select a node in the TreeView, you can use TreeView.SelectedNode
property to set the current selected node in the controls. It must be a
node in the TreeView's Nodes tree.

Please check the following link for more information:

http://msdn2.microsoft.com/en-us/lib...treeview.selec
tednode.aspx

Kevin Yu
Microsoft Online Community Support

================================================== ==========================
==========================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
================================================== ==========================
==========================

(This posting is provided "AS IS", with no warranties, and confers no
rights.)

May 10 '06 #3
Hallo Kevin,
thanks! I'll try that.

"Kevin Yu [MSFT]" wrote:
Hi Martin,

The TreeView doesn't support searching through its nodes. In this case you
have to write a search method, which go through all the nodes in the whole
tree and looks for the matched string. Then pass the TreeNode reference to
the SelectedNode property. HTH.

Kevin Yu
Microsoft Online Community Support

================================================== ==========================
==========================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
================================================== ==========================
==========================

(This posting is provided "AS IS", with no warranties, and confers no
rights.)

May 10 '06 #4
You're welcome!

Kevin Yu
Microsoft Online Community Support

================================================== ==========================
==========================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
================================================== ==========================
==========================

(This posting is provided "AS IS", with no warranties, and confers no
rights.)

May 11 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by someone | last post: by
4 posts views Thread by G Uljee | last post: by
3 posts views Thread by Saradhi | last post: by
2 posts views Thread by Stephen | last post: by
13 posts views Thread by André Nogueira | last post: by
3 posts views Thread by Michael_Burgess | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.