Reputation: 3189
In the case where I don't want a user to inadvertently delete text displayed in a textbox when the textbox is first loaded and displayed, e.g., by inadvertently fumble-fingering on the keyboard, how do I stop the text in the textbox from being automatically selected when first displayed and before the user has access to it?
Upvotes: 0
Views: 1117
Reputation: 164
Make the tabstop property of textbox false for which you want to disable the highlight do -
textBox1.TabStop = false;
This will stop highlighting the text of your textbox.
Upvotes: 3
Reputation: 3189
//set SelectionStart property to zero
//This clears the selection and sets the cursor to the left of the 1st character in the textbox
textBox1.SelectionStart = 0;
//This clears the selection and sets the cursor to the end of whatever is in the textbox
textBox1.SelectionStart = textBox1.Text.Length;
Upvotes: 1