C# .NET - select all the text in the textbox c# winform

Asked By fady sayegh on 18-Apr-06 08:15 AM
hi to all,

i'm trying to select all the text in a textbox control (winform) on the enter event.

textBox1.SelectionStart = 0;  
textBox1.SelectionLength = textBox1.TextLength;


when the enter event of the textbox si fired with the tab, the text is selected correctly.
but when the enter event of the textbox si fired with the mouse click, no text will be selected in textbox

does any body knows why ? if yes can you tell me what the solution is ?

best regards and thanks in advance

fady sayegh

GotFocus event on the textbox - Asked By J S on 18-Apr-06 08:55 AM

You might want to try the GotFocus event on the textbox.  You should be 
able to get this when you click into the control, and when you tab in. 
  Hope this helps.

Solution - Asked By Jesse Wong on 09-May-06 05:33 PM

Put the code into the textBox mousedown event.