Click here to Skip to main content
15,897,891 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Haii,


I have two textboxes. My requirement is i write some charecters in first text box,If that textbox is full,remaining Charecters will be display in next text box automatically depends upon first textbox width.
Posted

You need to set the max character limit for the first textbox. For example, if you set the limit to the 5 chars then on the textChanged event of the first textbox check the char length of it, and if it is equal to 5 then set focus to the second textbox and continue typing your text.

I don't know on what technology you're working on i.e Forms App or ASP .NET, that's why I am not able to code it. Below is the Forms App code,

C#
private void textBox1_TextChanged(object sender, EventArgs e)
{
   if (textBox1.TextLength == 5)  // check for the current chars in the textbox
   {
       textBox2.Focus();
   }
}



Hope it would help you. ;)

-KR
 
Share this answer
 
v4
Comments
Member 11570261 15-Jun-15 7:29am    
Thanks for replying..
I am using C# windows application. i don't want to set maxlength. My pronlem is my textbox with is very small. If i enter big text into that text box some charecters are not visible. i don't want to move the cursor left/right.TextBox charecters not more than textbox width.Remaining charecrters will display in other textbox.
Krunal Rohit 15-Jun-15 7:34am    
Then it's a designing issue. Still you can manually check how many characters can be fitted within that textbox width, and according to that you can set the TextLength.

It's not the best solution but give it a try.

-KR
Member 11570261 15-Jun-15 8:03am    
thank you..

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