Click here to Skip to main content
15,879,613 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hi,

when i tab from one control to another(textbox), then i want to select all text within that textbox?

thanks,
kk
Posted

Hi KK,

I tried with a text boxe(textbox1)in windows forms.
When textbox1 lost its focus, the content in the textboxt1 is selected

Sample code for you:
C#
private void textBox1_Leave(object sender, EventArgs e)
        {
            //Selects the content in the first control  
            textBox1.SelectAll();
        }

Hope this will help.
Happy programming!!!!
 
Share this answer
 
v2
You have to add Onfocus event in each textbox and in the event handler code
set all text selected as follows:
ASP.NET
<asp:textbox onfocus="javascript:this.select();" id="txt1" runat="server" xmlns:asp="#unknown" />
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900