如何阻止 Winforms 文本框中的文本在首次显示时自动 selected/highlighted?
How do I stop the text in a Winforms textbox from being automatically selected/highlighted when first displayed?
如果我不希望用户在首次加载和显示文本框时无意中删除显示在文本框中的文本,例如,无意中在键盘上摸索,我该如何停止文本在首次显示时和用户访问之前自动选择文本框?
//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;
将要禁用突出显示的文本框 false 的制表位设置为 属性 -
textBox1.TabStop = false;
这将停止突出显示文本框的文本。
如果我不希望用户在首次加载和显示文本框时无意中删除显示在文本框中的文本,例如,无意中在键盘上摸索,我该如何停止文本在首次显示时和用户访问之前自动选择文本框?
//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;
将要禁用突出显示的文本框 false 的制表位设置为 属性 -
textBox1.TabStop = false;
这将停止突出显示文本框的文本。