Some times it is useful to know whether a selection was made from code or by an userĀ since the AfterCheck event of a TreeView control is fired after both.
Use the code below to see how the selection was made:
private void tree1_AfterCheck(object sender, TreeViewEventArgs e)
{
   if (e.Action == TreeViewAction.ByKeyboard)
   {
      ..
   }
   if (e.Action == TreeViewAction.ByMouse)
   {
      ..
   }
}