MaskedTextBox Focus ?
-
Hi, I am developing applications on C # WinForm Using MaskedTextBox and Mask Structure (999) 000 00 00 I use Only when the user clicks with the mouse, it focuses on the pressed point This Data Entry Is Incorrect and Incomplete MaskedTextBox with User Mouse and Tab How I Can Focus on the Top of the Beginning I look forward to helping you in this regard Best Regards...
-
Hi, I am developing applications on C # WinForm Using MaskedTextBox and Mask Structure (999) 000 00 00 I use Only when the user clicks with the mouse, it focuses on the pressed point This Data Entry Is Incorrect and Incomplete MaskedTextBox with User Mouse and Tab How I Can Focus on the Top of the Beginning I look forward to helping you in this regard Best Regards...
I'm sorry, but that makes no sense at all to me. Perhaps an example would help?
Sent from my Amstrad PC 1640 Bad command or file name. Bad, bad command! Sit! Stay! Staaaay... AntiTwitter: @DalekDave is now a follower!
-
Hi, I am developing applications on C # WinForm Using MaskedTextBox and Mask Structure (999) 000 00 00 I use Only when the user clicks with the mouse, it focuses on the pressed point This Data Entry Is Incorrect and Incomplete MaskedTextBox with User Mouse and Tab How I Can Focus on the Top of the Beginning I look forward to helping you in this regard Best Regards...
ibrahimayhans wrote:
Only when the user clicks with the mouse, it focuses on the pressed point This Data Entry Is Incorrect and Incomplete
Your perception is incorrect. The described behaviour is default in Windows, and Windows apps should adhere to the standard.
ibrahimayhans wrote:
MaskedTextBox with User Mouse and Tab How I Can Focus on the Top of the Beginning
If you tab into it, you are at the beginning.
Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^] "If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
-
I'm sorry, but that makes no sense at all to me. Perhaps an example would help?
Sent from my Amstrad PC 1640 Bad command or file name. Bad, bad command! Sit! Stay! Staaaay... AntiTwitter: @DalekDave is now a follower!
But a Right Situation and a Problem When I'm Clicked and Moved to the Mouse How Can I Trigger the Home Key? SendKeys.Send("{HOME}"); It does not seem like it
-
ibrahimayhans wrote:
Only when the user clicks with the mouse, it focuses on the pressed point This Data Entry Is Incorrect and Incomplete
Your perception is incorrect. The described behaviour is default in Windows, and Windows apps should adhere to the standard.
ibrahimayhans wrote:
MaskedTextBox with User Mouse and Tab How I Can Focus on the Top of the Beginning
If you tab into it, you are at the beginning.
Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^] "If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
I'm Into Content With TAB Only User Uses Mouse Sometimes There are such Problems when you click
-
I'm Into Content With TAB Only User Uses Mouse Sometimes There are such Problems when you click
ibrahimayhans wrote:
Only User Uses Mouse Sometimes There are such Problems when you click
It is not a problem, it is how it is supposed to work. When activating a control with the mouse, the cursor does not go to the start but where you select. All controls work like that. Making it work differently means unexpected behaviour. Also, someone doing data-entry does not move to the next control using the mouse, it would make for very inefficient data-entry.
Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^] "If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
-
Hi, I am developing applications on C # WinForm Using MaskedTextBox and Mask Structure (999) 000 00 00 I use Only when the user clicks with the mouse, it focuses on the pressed point This Data Entry Is Incorrect and Incomplete MaskedTextBox with User Mouse and Tab How I Can Focus on the Top of the Beginning I look forward to helping you in this regard Best Regards...
I think you are asking how to move the textbox caret to position 0 when the empty textbox is clicked. The first part is to get the empty state of the maskedtextbox before any data has been entered. At that point the Text property value is not String.Empty but a representation of the mask. This 'empty' text can be obtained by capturing the Text when the MaskChanged event fires. For your example it is
"( ) "
The second part is picking a suitable place to move the caret. When an unfocussed textbox is clicked the sequence of Enter, GotFocus and Click events occur. You'll find that attempting to set the caret position in either the Enter or GotFocus events will fail and changes must be made in the Click event handler. Combining that information gives some prototype code
private String emptyText;
private void MaskedTextBox_MaskChanged(object sender, EventArgs e) {
// Capture the empty text
MaskedTextBox mtbx = (MaskedTextBox)sender;
emptyText = mtbx.Text;
}private void MaskedTextBox_Click(object sender, EventArgs e) {
MaskedTextBox mtbx = (MaskedTextBox)sender;
String currentText = mtbx.Text;
if (currentText == emptyText) {
// Move the caret to the start of the line
mtbx.Select(0, 0);
}
}EDIT : Correct operation of this code requires that the MaskChanged event handler is attached before the Mask is set. Alan.