In a textbox, how can u prevent the display of the blinking cursor when you click on it?
I did read in some forums that there is call to a particular api but when i
I am able to emulate Chrome's web address bar (partially) on a TextBox
using code from both here and this answer.
On first click, it selects all the the text without showing the blinking caret, the trick is to make the caret show itself when you click a second time on the selected text, which is how Chrome's web address bar behaves.
Here's the code:
[DllImport("user32.dll")]
static extern bool HideCaret(IntPtr hWnd);
private void textBox2_Enter(object sender, EventArgs e)
{
// Kick off SelectAll asyncronously so that it occurs after Click
BeginInvoke((Action)delegate
{
HideCaret(textBox2.Handle);
textBox2.SelectAll();
});
}