Click here to Skip to main content
15,888,461 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a MaskedTextBox from the Extended WPF Toolkit and I want to set the CaretIndex to 0 every time the user clicks on the TextBox.

What I have tried:

I have tried using the events MouseUp and GotFocus and tried setting the CaretIndex and the SelectionStart like so within these events;

C#
DateJoinedTextBox.SelectionStart = 0;


and

C#
DateJoinedTextBox.CaretIndex = 0;


but even after trying this the Caret position is still decided on where the user clicks, rather than being forced to 0.
Posted
Updated 14-Dec-16 0:39am
v3
Comments
Irina Pykhova 16-Dec-16 5:36am    
probably it is async operation. Try to set position using Dispatcher.BeginInvoke()

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