title: C# WindowsForm - How Detect if focus enter in textbox was by mouse click or tab
body: <p>i have this code to select all text in textbox if already have something wrote inside (TextLength > 0), it work perfect when i focus enter using tab on this textbox, then select all or not, little problem when focus in is made by mouse click, so i would like only to execute code bellow if focus enter isnt by mouse click, because if mouse click on textbox and it already have text, it will select all for about 0,1 seconds and unselect (but user can view blue select text than after unselect) and it isnt good</p>
  
  <p>My code:</p>
  
  <pre><code>private void txtValormetrocubico_Enter(object sender, EventArgs e)
  {
      if (txtValormetrocubico.TextLength &gt; 0)
      {
          txtValormetrocubico.SelectAll();
      }
  }
  </code></pre>
  
  <p>what i would like to do (incorrect syntax, only to understand my goal)</p>
  
  <pre><code>    private void txtValormetrocubico_Enter(object sender, EventArgs e)
      {
          if (isnt mouse_click)
          {
              if (txtValormetrocubico.TextLength &gt; 0)
              {
                  txtValormetrocubico.SelectAll();
              }
          } 
      }
  </code></pre>
  
  <p>Thanks</p>