You need to test first:
private void panel1_Click(object sender, EventArgs e)
{
if (treeView1.SelectedNode != null)
{
...
}
}
In addition, that does not add a new label each time the panel is clicked - you need to put the
label = new Label();
inside the method for that to happen.