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 中的文本会突出显示(选中)?


基础教程推荐
- 将事件 TextChanged 分配给表单中的所有文本框 2022-01-01
- 错误“此流不支持搜索操作"在 C# 中 2022-01-01
- 是否可以在 asp classic 和 asp.net 之间共享会话状态 2022-01-01
- JSON.NET 中基于属性的类型解析 2022-01-01
- 从 VS 2017 .NET Core 项目的发布目录中排除文件 2022-01-01
- 在 VS2010 中的 Post Build 事件中将 bin 文件复制到物 2022-01-01
- 首先创建代码,多对多,关联表中的附加字段 2022-01-01
- 如何动态获取文本框中datagridview列的总和 2022-01-01
- 经典 Asp 中的 ResolveUrl/Url.Content 等效项 2022-01-01
- 全局 ASAX - 获取服务器名称 2022-01-01