【发布时间】:2018-09-11 20:31:03
【问题描述】:
如果我不希望用户在第一次加载和显示文本框时无意中删除文本框中显示的文本,例如,无意中在键盘上摸索,我该如何停止文本框中的文本文本框在首次显示时和用户访问之前被自动选中?
【问题讨论】:
标签: c# winforms textbox highlight
如果我不希望用户在第一次加载和显示文本框时无意中删除文本框中显示的文本,例如,无意中在键盘上摸索,我该如何停止文本框中的文本文本框在首次显示时和用户访问之前被自动选中?
【问题讨论】:
标签: c# winforms textbox highlight
将要禁用突出显示的文本框的 tabstop 属性设置为 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;
【讨论】: