Shahid Ur Rehman Shahid Ur Rehman - 1 year ago 100 Question

select the text of wpf textbox on click

I have implemented mentioned code to select the text of WPF textbox but it doesn't work.
the event which fires is the "PreviewMouseDown"

txtQuantity.SelectionStart = 0
txtQuantity.SelectionLength = txtQuantity.Text.Length

Answer Source

Assuming that you want to select the text of a textbox, with a click on the textbox itself, this will work.

Event PreviewMouseUp,




txtQuantity.Select(start, length)

The event PreviewMouseDown doesn't work because, the effect done by mouse down is overruled by the event PreviewMouseUp which makes the real "Click". Try holding the mouse button to see this effect.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download