How can I programmatically click a TreeView TreeNode so it appears highlighted in the list and fires the AfterSelect event?

Is it because the TreeView doesn't have focus? Does setting the TreeView's HideSelection property to False change the behavior you're seeing?


After you set the SelectedNode. Try selecting the treeView. Worked for me anyway.

private void button1_Click(object sender, EventArgs e)
{
this.treeView1.SelectedNode = this.treeView1.Nodes[1];
this.treeView1.Select();
}

Try this to make the selected node bold:

selectedNode.NodeFont = new System.Drawing.Font(
    selectedNode.TreeView.Font,
    selectedNode.TreeView.Font.Style | FontStyle.Bold);

// You need to append an emptry string to work around this bug: 
// http://support.microsoft.com/kb/937215
selectedNode.Text += string.Empty;