title: C# how do I ensure the selected node remains highlighted when focus lost
body: <p>I have changed the Treeview.HideSelection = false; 
  But how do I insure that when focus is lost that the selected item remains the original selected color?</p>
  
  <p>EDIT:</p>
  
  <p>I have a listview on a form that holds a list of process events. Alongside the Treeview on the same form is a series of selections that the user completes to classify the event in the listview. However, when the user makes a selection on one of the classification controls the blue highlighted selected Treeview item turns to a grey color. I was hoping to find the property that defines this color to make it the same color blue.</p>
  
  <p>Any suggestions.</p>
  
  <p>Update:</p>
  
  <pre><code> public partial class myTreeView : TreeView
  {
      TreeNode tn = null;
      public myTreeView()
      {
          InitializeComponent();
      }
  
      protected override void OnAfterSelect(TreeViewEventArgs e)
      {
          if (tn != null)
          {
              tn.BackColor = this.BackColor;
              tn.ForeColor = this.ForeColor;
          }
          tn = e.Node;
          base.OnAfterSelect(e);
      }
      protected override void OnBeforeSelect(TreeViewCancelEventArgs e)
      {
  
          e.Node.BackColor = Color.Green;
          e.Node.ForeColor = Color.White;
          base.OnBeforeSelect(e);
      }
      protected override void OnGotFocus(System.EventArgs e)
      {
  
          base.OnGotFocus(e);
      }
  
      protected override void OnLostFocus(System.EventArgs e)
      {
  
          if (tn != null)
          {
              tn.BackColor = Color.Green;
              tn.ForeColor = Color.White;
          }
          // tn.BackColor = Color.Red;
  
          base.OnLostFocus(e);
      }
  }
  </code></pre>