472,811 Members | 1,971 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,811 software developers and data experts.

Search and select an item from treeview

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
4 20312
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Polo | last post by:
Hi, I search a TreeView control with these features : Each node can be have : A label A CheckBox + Label A Radio button + Label Thank's
2
by: tmaster | last post by:
I can detect a right click on my treeview, but SelectedNode.Index points to the last node that was left-clicked. Is there a way for a right-click event of a treeview to update the...
1
by: Patrick | last post by:
This may be a simple question but how can I make the tree change the selected node... on a right click .. in addition to the left click? What I want is to filter my context menu based on the type...
13
by: André Nogueira | last post by:
Hi there. I know you can view a node's fullpath property, but is it posible to select a node using its path? Like, tell the treeview that the node that should be selected is the node with the...
4
by: deepee | last post by:
I have a drop down box in HTML using SELECT and OPTION tags: <select title="Choose a number" onchange="obscure()" name="Digit1" ID="Digit1"> <OPTION VALUE="">&nbsp;</OPTION> <OPTION...
3
by: Michael_Burgess | last post by:
Hi there, I've looked around the different groups and still can't figure this out without resorting to scrappy code............ I want to programtically select and highlight a TreeView node,...
0
by: frankliu | last post by:
I am using List View Control in my program. It works fine when adding new items, updating items, or deleting items. But I cannot search a item with LVM_FINDITEM message. It always return -1 when...
0
by: Zuhaib Hyder | last post by:
how to select asp:TreeView nodes through skin??? (not working) or tell me any other way, through css etc.... selected node not working
5
by: =?Utf-8?B?dmlubw==?= | last post by:
Hello I have created a TreeView and i wish to select a node into it and then expand the selected node. Is someone has an idea ? Thanks
1
by: gayat jain | last post by:
jsf <h:select item> how i can call bean method one click any select item
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.