I need some assistance with the following code, I am trying to get the code to check if a node exists in the treeview then select it.
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
if (dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value != null)
{
string CellSelected = dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString();
if (treeView1.Nodes.ContainsKey(CellSelected))
{
this.treeView1.SelectedNode.Name = CellSelected;
this.treeView1.Select();
}
}
}
once the treeview node is selected it needs to fire the following code
private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
{
pictureBox1.Image = null;
dataGridView1.Visible = false;
if(treeView1.SelectedNode.Name=="test")
{
pictureBox1.Image = _1.Properties.Resources._7E7907_2;
}
I haven't used treeviews particularly much, but have you considered you might have to do a recursive search through all nodes, and child nodes, and child of child nodes, and so forth? As far as I can tell, you're only looping through the first layer of treeview nodes.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments