void TreeView1_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e) { if (TreeView1.SelectedNode.Index == 0) { Panel1.Visible = true; Panel2.Visible = false; TreeView1.Focus(); } else if (TreeView1.SelectedNode.Index == 1) { Panel1.Visible = false; Panel2.Visible = true; TreeView1.Focus(); } }