关于SelectAll的问题 [英] Question on SelectAll

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

问题描述

在几个文本框的GotFocus事件中,我包含了诸如

" txtMyTxtBox.SelectAll"之类的代码。当我从文本框切换到文本框时,获得焦点的

文本框中的文本被按预期选中但如果我使用鼠标来点击文本框,则文本不是选择。我怀疑这有什么东西

与各种事件发生的命令有关?在VB6中这很有用。


有没有人对这里发生的事情有任何建议和/或

当鼠标用于鼠标时获取文本的方法改变焦点?


Wayne

In the GotFocus event for several text boxes I include code such as
"txtMyTxtBox.SelectAll". When I tab from textbox to textbox the text in the
textbox that got focus is selected as expected but if I use the mouse to
click on the textbox the text is not selected. I suspect this has something
to do with the order in which the various events fire? In VB6 this worked.

Does anyone have any suggestions regarding what is happening here and/or
ways to get the text selected when a mouse is used for changing focus?

Wayne

推荐答案

你应该使用''enter''事件 - 而不是gotfocus活动


" Wayne Wengert" < WA *************** @ wengert.com>在消息中写道

新闻:OV ************* @ TK2MSFTNGP11.phx.gbl ...
you should use the ''enter'' event - not the gotfocus event

"Wayne Wengert" <wa***************@wengert.com> wrote in message
news:OV*************@TK2MSFTNGP11.phx.gbl...
在几个GotFocus事件中文本框我包括诸如
txtMyTxtBox.SelectAll之类的代码。当我从文本框到文本框中选择
中的文本时,获得焦点的文本框将按预期选择,但如果我使用鼠标单击文本框,则不会选择文本。我怀疑这有
与各种事件发生的命令有关?在VB6中,这有效。

有没有人对这里发生的事情有任何建议和/或
当使用鼠标来改变焦点时选择文本的方法?
< Wayne
In the GotFocus event for several text boxes I include code such as
"txtMyTxtBox.SelectAll". When I tab from textbox to textbox the text in the textbox that got focus is selected as expected but if I use the mouse to
click on the textbox the text is not selected. I suspect this has something to do with the order in which the various events fire? In VB6 this worked.

Does anyone have any suggestions regarding what is happening here and/or
ways to get the text selected when a mouse is used for changing focus?

Wayne



---

邮件已通过无病毒验证。

由AVG反查病毒系统( http://www.grisoft.com)

版本:6.0.744 /病毒库:496 - 发布日期:2004年8月24日


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.744 / Virus Database: 496 - Release Date: 8/24/2004


Hal;


我甚至都不知道。让我试试你的建议。 BTW,是LostFocus

离开物体时仍然是最好用的(我想重置背景

颜色)


Wayne


" Hal Rosser" < HM ****** @ bellsouth.net>在消息中写道

新闻:_i ******************* @ bignews1.bellsouth.net。 ..
Hal;

I wasn''t even aware of that. Let me try you suggestion. BTW, is LostFocus
still the best to use when leaving an object (I want to reset the background
color)

Wayne

"Hal Rosser" <hm******@bellsouth.net> wrote in message
news:_i*******************@bignews1.bellsouth.net. ..
你应该使用''enter''事件 - 而不是gotfocus事件

Wayne Wengert < WA *************** @ wengert.com>在消息中写道
新闻:OV ************* @ TK2MSFTNGP11.phx.gbl ...
you should use the ''enter'' event - not the gotfocus event

"Wayne Wengert" <wa***************@wengert.com> wrote in message
news:OV*************@TK2MSFTNGP11.phx.gbl...
在我参与的几个文本框的GotFocus事件中代码如
" txtMyTxtBox.SelectAll"。当我从文本框到文本框中选择
In the GotFocus event for several text boxes I include code such as
"txtMyTxtBox.SelectAll". When I tab from textbox to textbox the text in

中的文本时,

获得焦点的文本框被按预期选择但如果我使用鼠标点击文本框文本未被选中。我怀疑这有
textbox that got focus is selected as expected but if I use the mouse to
click on the textbox the text is not selected. I suspect this has

与各种事件触发的顺序有关吗?在VB6中这个
工作了。
有没有人对这里发生的事情有什么建议和/或
当用鼠标来改变焦点时选择文本的方法?
< Wayne
to do with the order in which the various events fire? In VB6 this worked.
Does anyone have any suggestions regarding what is happening here and/or
ways to get the text selected when a mouse is used for changing focus?

Wayne



---
发送邮件经过无病毒认证。
由AVG反病毒系统检查( http://www.grisoft.com)
版本:6.0.744 /病毒库:496 - 发布日期:2004年8月24日


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.744 / Virus Database: 496 - Release Date: 8/24/2004



Hal;


我试过使用你建议的输入事件(我确实看到有一个

对应的Leave事件)但是虽然事件触发并且文本框的背景颜色发生了变化,它仍然没有选择文本。在下面的代码

中,SetBackground子只是更改文本框的背景颜色 -

,以帮助用户查看哪些对象具有焦点。如果我浏览代码我可以

看到SelectAll正在执行但是文本没有结束

被选中 - 我会做一些挖掘输入事件。


Private Sub txtAssocContactLastName_Enter(ByVal sender As Object,ByVal e As

System.EventArgs)处理txtAssocContactLastName.Enter


SetBackground()


txtAssocContactLastName.SelectAll()


结束子


Wayne


" Hal Rosser" < HM ****** @ bellsouth.net>在消息中写道

新闻:_i ******************* @ bignews1.bellsouth.net。 ..
Hal;

I tried using the enter event as you suggested (and I do see that there is a
corresponding Leave event) but although the event fires and the background
color of the textbox changes, it still does not select the text. In the code
below, the SetBackground sub simply changes the textbox''s background color -
to help the user see what object has focus. If I walk through the code I can
see that the SelectAll is being executed but the text does not end up
selected - I''ll do some digging about the enter event.

Private Sub txtAssocContactLastName_Enter(ByVal sender As Object, ByVal e As
System.EventArgs) Handles txtAssocContactLastName.Enter

SetBackground()

txtAssocContactLastName.SelectAll()

End Sub

Wayne

"Hal Rosser" <hm******@bellsouth.net> wrote in message
news:_i*******************@bignews1.bellsouth.net. ..
你应该使用''enter''事件 - 而不是gotfocus事件

Wayne Wengert < WA *************** @ wengert.com>在消息中写道
新闻:OV ************* @ TK2MSFTNGP11.phx.gbl ...
you should use the ''enter'' event - not the gotfocus event

"Wayne Wengert" <wa***************@wengert.com> wrote in message
news:OV*************@TK2MSFTNGP11.phx.gbl...
在我参与的几个文本框的GotFocus事件中代码如
" txtMyTxtBox.SelectAll"。当我从文本框到文本框中选择
In the GotFocus event for several text boxes I include code such as
"txtMyTxtBox.SelectAll". When I tab from textbox to textbox the text in

中的文本时,

获得焦点的文本框被按预期选择但如果我使用鼠标点击文本框文本未被选中。我怀疑这有
textbox that got focus is selected as expected but if I use the mouse to
click on the textbox the text is not selected. I suspect this has

与各种事件触发的顺序有关吗?在VB6中这个
工作了。
有没有人对这里发生的事情有什么建议和/或
当用鼠标来改变焦点时选择文本的方法?
< Wayne
to do with the order in which the various events fire? In VB6 this worked.
Does anyone have any suggestions regarding what is happening here and/or
ways to get the text selected when a mouse is used for changing focus?

Wayne



---
发送邮件经过无病毒认证。
由AVG反病毒系统检查( http://www.grisoft.com)
版本:6.0.744 /病毒库:496 - 发布日期:2004年8月24日


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.744 / Virus Database: 496 - Release Date: 8/24/2004



这篇关于关于SelectAll的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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