I'm using a WPF TextBox, and I'm calling the Select()
method to make a selection. Unfortunately, it doesn't seem to work unless I select something manually first. Can someone suggest as to why it happens?
Does your textbox have focus when you call the Select method?
The selection will not show unless it has focus, but the common way for the textbox to get focus is by clicking on it...which deselects the text. This behaviour could give the impression that it's not working.
Calling TextBox.Focus() after (or before) calling Select() should fix it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With