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:
The program doesn't see the highlighted one as selected
This is my code:
Code:
private void ClearRecursive(TreeNode treeNode) { foreach (TreeNode tn in treeNode.Nodes) { tn.BackColor = Color.White; ClearRecursive(tn); } } private void ClearBackColor() { TreeNodeCollection nodes = tvLocations.Nodes; foreach (TreeNode n in nodes) { ClearRecursive(n); } } private void FindByText() { TreeNodeCollection nodes = tvLocations.Nodes; foreach (TreeNode n in nodes) { FindRecursive(n); } } private void FindRecursive(TreeNode treeNode) { try { foreach (TreeNode tn in treeNode.Nodes) { // if the text properties match, color the item if (tn.Text == this.txtFindLoc.Text) tn.BackColor = Color.Yellow; FindRecursive(tn); } } catch (Exception ed) { MessageBox.Show("No Macthes were found!"); } } private void btnFindLoc_Click(object sender, EventArgs e) { ClearBackColor(); FindByText(); string ConnString = Properties.Settings.Default.GriffenConnectionString.ToString(); OleDbConnection Conn = new OleDbConnection(ConnString); string sql = ""; DataSet dsFillLocation = new DataSet(); { sql = "Select * from qx_AssetLocation where alc__id <> " + tvLocations.SelectedNode.Tag.ToString(); OleDbDataAdapter daLocFill = new OleDbDataAdapter(sql.ToString(), Conn); daLocFill.Fill(dsFillLocation, "qx_AssetLocation"); if (dsFillLocation != null) { cboLocationName.DataSource = dsFillLocation.Tables["qx_AssetLocation"]; cboLocationName.DisplayMember = "ALC__DESCRIPTION"; cboLocationName.ValueMember = "ALC__ID"; } } tvLocations.ExpandAll(); } }
Comment