Hello,
I have two textboxes txt1 and txt2. I have set the maxlength of the txt1 to 5. When it reaches the maxlength it shifts the focus to txt2. The problem is on keypress event when I come back and make some corrections it shifts focus to the next textbox which I do not want to happen.
Eg: I have "BRAIN" in txt1 and when I come back and wanted it to change to BRIAN. it is not letting me to change the entire text instead when I press any key it shifts focus to the next textbox even when I select the text by mouse and keyboard. I want to make the necessary changes and when I reach the limit of maxlength I want the focus to be shifted. How to overcome this problem?
Rajanikant HawaldarPosted Nov 19, 2023, 3:59 PM
Use flag to achieve it,
Amit MohantyPosted Nov 17, 2023, 5:49 AM
You can use
txt1_KeyDownevent prevents moving the focus totxt2on keypress if the maximum length is already reached, except when the pressed key is the "Backspace" key (Keys.Back). For example:kemli zurdoPosted Nov 16, 2023, 9:05 PM
I can select the first character but when I press any key it shifts the focus to the next textbox.
Sam HobbsPosted Nov 16, 2023, 8:56 PM
If txt1 has BRAIN then can you delete a character first and then add a character? If that works and you need something else to happen then you will need to write code to do what you need instead of using maxlength.