473,410 Members | 1,904 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,410 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 20359
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
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.