在文本框中选择文本 [英] Text is selected in the text box

查看:44
本文介绍了在文本框中选择文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我加载表单时,其中一些文本已被赋予文本框.该文本框中的所有文本都突出显示.我希望 vb 不要以这种方式加载它.如何修复它.谢谢富可纳

When I load the form where some text has been given to text box. All the text in that textbox is highlighted. I want vb not to load it this way. How to fix it. Thanks Furqna

推荐答案

您可以将文本框上的选项卡索引设置为其他内容,使其不是最低索引.

You could set the tab index on your textbox to something else so that it's not the lowest index.

您可以在 form.activated 事件中设置 TextBox1.SelectionLength = 0.

You could set the TextBox1.SelectionLength = 0 in the form.activated event.

我不太喜欢这个,因为如果用户将文本 hilited 和最小化应用程序,那么他们将丢失 hilite,但很容易做到.我想你可以使用一个标志来确保它只在第一次激活时执行.

I don't like this as much because if the user had the text hilited and minized the application then they will lose the hilite, but is fairly easy to do. I guess you could use a flag to make sure it only did it on the first activate.

您可以在加载中设置一个计时器事件以在加载事件后立即清除它,但这似乎有点过分了.由于诸如此类的问题,我曾在他们有一个标准函数的地方工作,该函数在加载后 100 毫秒发生在每个表单上.

You could set a timer event in the load to clear it immediately after the load event, but that seems like overkill. I have worked at places where they had a standard function that happened on every form 100 ms after load because of problems such as this.

这篇关于在文本框中选择文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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