Why is text in TextBox highlighted (selected) when form is displayed?(为什么在显示表单时 TextBox 中的文本会突出显示(选中)?)
问题描述
我在 C# 中有一个包含 TextBox 的表单,我将其设置为如下字符串:
I have a form containing a TextBox in C# which I set to a string as follows:
textBox.Text = str;
表单显示时,为什么texbox中的文字会高亮/选中?
When the form is displayed, why does the text in the texbox appear highlighted/selected?
推荐答案
文本框的 TabIndex 为 0,TabStop 设置为 true.这意味着当窗体显示时,控件将获得焦点.
The text box has a TabIndex of 0 and TabStop set to true. This means that the control will be given focus when the form is displayed.
您可以给另一个控件 0 TabIndex(如果有的话)并给文本框一个不同的标签索引 (>0),或者将 TabStop 设置为文本框为 false 以阻止这种情况发生.
You can either give another control the 0 TabIndex (if there is one) and give the text box a different tab index (>0), or set TabStop to false for the text box to stop this from happening.
这篇关于为什么在显示表单时 TextBox 中的文本会突出显示(选中)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:为什么在显示表单时 TextBox 中的文本会突出显示(选中)?
基础教程推荐
- 禁止输入少量字符,例如'<'、'&a 2022-01-01
- 当值可以是对象或空数组时反序列化 JSON 2022-01-01
- Moq It.Is<>不匹配 2022-01-01
- .NET SerialPort DataReceived 事件未触发 2022-01-01
- WPF 模态进度窗口 2022-01-01
- 如果有人提交恶意软件Nuget包怎么办? 2022-01-01
- C# 从 List<List<int>> 中删除重 2022-01-01
- Azure Functions:CosmosDBTrigger 未在 Visual Studio 中触发 2022-01-01
- 我应该在后面的代码中直接使用 Linq To SQL 还是使 2022-01-01
- 如何使用 .Net 检查 Active Directory 服务器是否已启动并正在运行? 2022-01-01
