gpt4 book ai didi

c# - 如何选择 Windows 窗体文本框中的所有文本?

转载 作者:IT王子 更新时间:2023-10-29 04:52:04 24 4
gpt4 key购买 nike

我想选择文本框中的所有文本。

我已经尝试使用下面的代码:

textBoxResults.SelectionStart = 0;
textBoxResults.SelectionLength = textBoxResults.Text.Length;

来源:我从这里得到这段代码 http://msdn.microsoft.com/en-us/library/vstudio/hk09zy8f(v=vs.100).aspx但出于某种原因,它似乎不起作用 - 意思是,没有文本被选中

最佳答案

您可以为此目的使用内置方法。

textBoxResults.SelectAll();
textBoxResults.Focus(); //you need to call this to show selection if it doesn't has focus

关于c# - 如何选择 Windows 窗体文本框中的所有文本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18050714/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com