C# WindowsForm - How Detect if focus enter in textbox was by mouse click or tab -


i have code select text in textbox if have wrote inside (textlength > 0), work perfect when focus enter using tab on textbox, select or not, little problem when focus in made mouse click, execute code bellow if focus enter isnt mouse click, because if mouse click on textbox , have text, select 0,1 seconds , unselect (but user can view blue select text after unselect) , isnt good

my code:

private void txtvalormetrocubico_enter(object sender, eventargs e) {     if (txtvalormetrocubico.textlength > 0)     {         txtvalormetrocubico.selectall();     } } 

what (incorrect syntax, understand goal)

    private void txtvalormetrocubico_enter(object sender, eventargs e)     {         if (isnt mouse_click)         {             if (txtvalormetrocubico.textlength > 0)             {                 txtvalormetrocubico.selectall();             }         }      } 

thanks

in form's constructor can hook gotfocus event

public form1() {     textbox1.gotfocus += textbox1_gotfocus; }  void textbox1_gotfocus(object sender, eventargs e) {     throw new notimplementedexception(); } 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -