How do you auto highlight text in a textbox control when the control gains focus.
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Carriage Return (ASCII chr 13) is missing from tex
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
You can use this, pithy. :D
In asp.net:
If your intention is to get the text in the textbox highlighted on a mouse click you can make it simple by adding:
in:
where textBox1 is the name of the relevant textbox located in Form1
And then create the method definition:
in:
If you wanted to only select all the text when the user first clicks in the box, and then let them click in the middle of the text if they want, this is the code I ended up using.
Just handling the
FocusEnter
event doesn't work, because theClick
event comes afterwards, and overrides the selection if youSelectAll()
in the Focus event.In Windows Forms and WPF: