winforms 如何在三次点击时高亮显示整个文本框?

bzzcjhmw  于 2023-02-24  发布在  其他
关注(0)|答案(1)|浏览(143)

当输入文本框中的文本之间有空格时,我的三次单击只会突出显示下一个空格,而不是整个文本框。

klr1opcd

klr1opcd1#

订阅DoubleClick事件:

private void textBox1_DoubleClick(object sender, EventArgs e)
{
    textBox1.SelectionStart = 0;  // set the selection start index to the beginning
    textBox1.SelectionLength = textBox1.Text.Length;  // set the selection length to the length of the text
}

https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.control.doubleclick?view=windowsdesktop-7.0

相关问题