为什么在显示表单时 TextBox 中的文本会突出显示(选中)? [英] Why is text in TextBox highlighted (selected) when form is displayed?

查看:10
本文介绍了为什么在显示表单时 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 中的文本会突出显示(选中)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆