473,398 Members | 2,113 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,398 software developers and data experts.

Searching Nodes (need Info after found)

Sl1ver
196 100+
I've implemented search for my nodes if found it will highlight the node yellow but the nodes is programed to show information about it after its selected how will i achieve the information to be shown after the node was found?
The program doesn't see the highlighted one as selected

This is my code:
Expand|Select|Wrap|Line Numbers
  1.  private void ClearRecursive(TreeNode treeNode)
  2.         {
  3.             foreach (TreeNode tn in treeNode.Nodes)
  4.             {
  5.                 tn.BackColor = Color.White;
  6.                 ClearRecursive(tn);
  7.             }
  8.         }
  9.         private void ClearBackColor()
  10.         {
  11.             TreeNodeCollection nodes = tvLocations.Nodes;
  12.             foreach (TreeNode n in nodes)
  13.             {
  14.                 ClearRecursive(n);
  15.             }
  16.         }
  17.         private void FindByText()
  18.         {
  19.             TreeNodeCollection nodes = tvLocations.Nodes;
  20.             foreach (TreeNode n in nodes)
  21.             {
  22.                 FindRecursive(n);
  23.             }
  24.         }
  25.  
  26.         private void FindRecursive(TreeNode treeNode)
  27.         {
  28.             try
  29.             {
  30.                 foreach (TreeNode tn in treeNode.Nodes)
  31.                 {
  32.                     // if the text properties match, color the item
  33.                     if (tn.Text == this.txtFindLoc.Text)
  34.  
  35.                         tn.BackColor = Color.Yellow;
  36.  
  37.  
  38.  
  39.                     FindRecursive(tn);
  40.                 }
  41.             }
  42.             catch (Exception ed)
  43.             {
  44.                 MessageBox.Show("No Macthes were found!");
  45.             }
  46.         }
  47.  
  48.         private void btnFindLoc_Click(object sender, EventArgs e)
  49.         {
  50.             ClearBackColor();
  51.             FindByText();
  52.             string ConnString = Properties.Settings.Default.GriffenConnectionString.ToString();
  53.  
  54.             OleDbConnection Conn = new OleDbConnection(ConnString);
  55.  
  56.  
  57.             string sql = "";
  58.             DataSet dsFillLocation = new DataSet();
  59.  
  60.             {
  61.                 sql = "Select * from qx_AssetLocation where alc__id <> " + tvLocations.SelectedNode.Tag.ToString();
  62.                 OleDbDataAdapter daLocFill = new OleDbDataAdapter(sql.ToString(), Conn);
  63.                 daLocFill.Fill(dsFillLocation, "qx_AssetLocation");
  64.  
  65.                 if (dsFillLocation != null)
  66.                 {
  67.                     cboLocationName.DataSource = dsFillLocation.Tables["qx_AssetLocation"];
  68.                     cboLocationName.DisplayMember = "ALC__DESCRIPTION";
  69.                     cboLocationName.ValueMember = "ALC__ID";
  70.                 }
  71.             }
  72.  
  73.             tvLocations.ExpandAll();
  74.  
  75.  
  76.  
  77.         }
  78.  
  79.         }
Apr 20 '09 #1
1 1601
tlhintoq
3,525 Expert 2GB
That's because you didn't make it the selected node, you only changed the background color. You need to make it the selected node of the treeview. Jump on MSDN and read the methods for a treeview.
Apr 21 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Mr Chat | last post by:
Hello all I am trying to write a specialist outlining tool, using the TreeView control (in VB5 running on W95). It has gone quite well so far. I have found some very useful info on how to...
1
by: helpful sql | last post by:
Hi all, Following is a sample code from my xml file. <w:body> <ns0:Mpi> <ns0:User> <ns0:Address1> </ns0:Address1> </ns0:User>
1
by: tMan | last post by:
whats the xpath to get all the empty nodes in a document. in the xml below i want to get the nodes <empty> and <t> all other nodes either have a child node or text in them <root> <test> <se>...
1
by: Christian Rühl | last post by:
hey! what i wanna do sounds very simple at first, but it turned out to be a real bone crusher... i want to check if a treeView node is checked and if a correspondent node in my xml config file...
1
by: Christian Rühl | last post by:
hey! what i wanna do sounds very simple at first, but it turned out to be a real bone crusher... i want to check if a treeView node is checked and if a correspondent node in my xml config file...
15
by: Gigs_ | last post by:
Hi all! I have text file (english-croatian dictionary) with words in it in alphabetical order. This file contains 179999 words in this format: english word: croatian word I want to make...
1
by: j_depp_99 | last post by:
I would like to know what would be the best way to count the nodes accessed while searching for an item in a binary search tree. I have to keep a tally for each item I search for. I have included...
1
by: empiresolutions | last post by:
Howdy, I have an PHP page that edits XML files. I want ADD a new *id* attribute to all nodes on the page that do not have it all ready. Then i want to delete all of the values of *id* and set...
9
by: drhowarddrfine | last post by:
I don't want to use a db manager, like mysql, for such a small database but I'm finding this trickier than I thought and hope someone can provide some guidance. I have a restaurant menu with...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.