By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,901 Members | 1,436 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,901 IT Pros & Developers. It's quick & easy.

Search and select an item from treeview

P: n/a
How can I find and select an specific item in an treeview control?

I want to create a search feature on my treeview.

Thanks in advance,

Gaby
Nov 15 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
You'll have to implement a SelectItem method yourself - and for that, you'll
probably have to recurse through all the nodes of the tree view and select
the one that matches your criteria.

-vJ

"G Uljee" <le***@xs4all.nl> wrote in message
news:3f*********************@news.xs4all.nl...
How can I find and select an specific item in an treeview control?

I want to create a search feature on my treeview.

Thanks in advance,

Gaby

Nov 15 '05 #2

P: n/a
I've already try that, see code.
My question now is how can I select the specific node?
private void bSearch_Click(object sender, System.EventArgs e)
{
TreeNode currentnode = new TreeNode();
try
{
foreach (TreeNode node in this.tvw.Nodes)
{
if (node.Text.Substring(0,this.tSearch.Text.Length).T oLower() ==
this.tSearch.Text.ToLower())
{
MessageBox.Show("2");
break;
}
else
foreach (TreeNode node1 in node.Nodes)
{
if (node1.Text.Substring(0,this.tSearch.Text.Length). ToLower() ==
this.tSearch.Text.ToLower())
{
MessageBox.Show("2");
break;
}
else
{
foreach (TreeNode node2 in node1.Nodes)
{
if (node2.Text.Substring(0,this.tSearch.Text.Length). ToLower() ==
this.tSearch.Text.ToLower())
{
currentnode = node2;
break;
}
}
}
}
}

Gaby

"Vijaye Raji" <no************@hotmail.com> wrote in message
news:eI**************@tk2msftngp13.phx.gbl...
You'll have to implement a SelectItem method yourself - and for that, you'll probably have to recurse through all the nodes of the tree view and select
the one that matches your criteria.

-vJ

"G Uljee" <le***@xs4all.nl> wrote in message
news:3f*********************@news.xs4all.nl...
How can I find and select an specific item in an treeview control?

I want to create a search feature on my treeview.

Thanks in advance,

Gaby


Nov 15 '05 #3

P: n/a
tvw.SelectedNode = node;

-vJ

"G Uljee" <le***@xs4all.nl> wrote in message
news:3f*********************@news.xs4all.nl...
I've already try that, see code.
My question now is how can I select the specific node?
private void bSearch_Click(object sender, System.EventArgs e)
{
TreeNode currentnode = new TreeNode();
try
{
foreach (TreeNode node in this.tvw.Nodes)
{
if (node.Text.Substring(0,this.tSearch.Text.Length).T oLower() ==
this.tSearch.Text.ToLower())
{
MessageBox.Show("2");
break;
}
else
foreach (TreeNode node1 in node.Nodes)
{
if (node1.Text.Substring(0,this.tSearch.Text.Length). ToLower() ==
this.tSearch.Text.ToLower())
{
MessageBox.Show("2");
break;
}
else
{
foreach (TreeNode node2 in node1.Nodes)
{
if (node2.Text.Substring(0,this.tSearch.Text.Length). ToLower() ==
this.tSearch.Text.ToLower())
{
currentnode = node2;
break;
}
}
}
}
}

Gaby

"Vijaye Raji" <no************@hotmail.com> wrote in message
news:eI**************@tk2msftngp13.phx.gbl...
You'll have to implement a SelectItem method yourself - and for that,

you'll
probably have to recurse through all the nodes of the tree view and select the one that matches your criteria.

-vJ

"G Uljee" <le***@xs4all.nl> wrote in message
news:3f*********************@news.xs4all.nl...
How can I find and select an specific item in an treeview control?

I want to create a search feature on my treeview.

Thanks in advance,

Gaby



Nov 15 '05 #4

P: n/a
tvw.SelectedNode = node2;

tvw.Select();

tvw.Focus();

that's the solution...

Cheers...

"Vijaye Raji" <no************@hotmail.com> wrote in message
news:uv**************@TK2MSFTNGP12.phx.gbl...
tvw.SelectedNode = node;

-vJ

"G Uljee" <le***@xs4all.nl> wrote in message
news:3f*********************@news.xs4all.nl...
I've already try that, see code.
My question now is how can I select the specific node?
private void bSearch_Click(object sender, System.EventArgs e)
{
TreeNode currentnode = new TreeNode();
try
{
foreach (TreeNode node in this.tvw.Nodes)
{
if (node.Text.Substring(0,this.tSearch.Text.Length).T oLower() ==
this.tSearch.Text.ToLower())
{
MessageBox.Show("2");
break;
}
else
foreach (TreeNode node1 in node.Nodes)
{
if (node1.Text.Substring(0,this.tSearch.Text.Length). ToLower() ==
this.tSearch.Text.ToLower())
{
MessageBox.Show("2");
break;
}
else
{
foreach (TreeNode node2 in node1.Nodes)
{
if (node2.Text.Substring(0,this.tSearch.Text.Length). ToLower() ==
this.tSearch.Text.ToLower())
{
currentnode = node2;
break;
}
}
}
}
}

Gaby

"Vijaye Raji" <no************@hotmail.com> wrote in message
news:eI**************@tk2msftngp13.phx.gbl...
You'll have to implement a SelectItem method yourself - and for that,

you'll
probably have to recurse through all the nodes of the tree view and select the one that matches your criteria.

-vJ

"G Uljee" <le***@xs4all.nl> wrote in message
news:3f*********************@news.xs4all.nl...
> How can I find and select an specific item in an treeview control?
>
> I want to create a search feature on my treeview.
>
> Thanks in advance,
>
>
>
> Gaby
>
>



Nov 15 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.