将焦点设置为窗体上的控件 [英] Setting Focus to A Control on a Form

查看:64
本文介绍了将焦点设置为窗体上的控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道我已经在某个地方完成了这项工作,但我在测试代码的任何

中找不到任何示例。


我有一个具有由数据集填充的列表框的表单,它填充各​​种

文本框。


当表单首次打开时,我必须选中列表框以便我可以在列表中滚动




我如何设置焦点到列表框(我知道我可以更改Tab键顺序但是我

以为我可以用setfocus方法移动它。


谢谢


查理


- 原始消息-----
我知道我已经在某个地方完成了这个,但是在我的测试代码中找不到任何
的例子。

我有一个带有由数据集
填充的列表框的表单,它填写各种文本框。

表单首次打开时,我必须选中列表到列表box
这样我就可以滚动列表。

如何setfocus到列表框(我知道我可以更改
的Tab键顺序但是我想我可以用它来移动它setfocus方法)

感谢

查理



谢谢BB

我曾经尝试过,但它没有奏效。然后我回去看看我是否已经做错了什么错误

并且发现我把代码放错了。


谢谢

Charlie

< an ******* @ discussion.microsoft.com>在留言中写道

news:05 **************************** @ phx.gbl ... < blockquote class =post_quotes>你试过myListbox.Focus()吗?
BB

-----原帖-----
我知道我已经在某个地方完成了这个但我在我的测试代码的任何

中找不到任何


示例。
我有一个带有由数据集填充的列表框的表单


它填写各种

文本框。

表单首次打开时,我必须选中列表框


以便我可以在列表中滚动



如何设置焦点到列表框(我知道)我可以更改


Tab键顺序,但是我

以为我可以使用setfocus方法移动它。

谢谢

查理



On Thu,2003年12月4日06:22:08 GMT ,查尔斯·梅

< qu ********* @ hotmail.com>写道:

谢谢BB
我曾尝试过,但它没有奏效。然后我回去看看我是否做错了
并发现我把代码放错了。



你应该把它放进去在表单的Load事件中,一旦表单加载,焦点就是

。确保控件启用了

tabstop属性


I know I''ve done this somewhere but I cannot find any example of it in any
of my test code.

I have a form with a Listbox that is filled by a dataset it fills in various
textboxes.

When the form first opens, I have to tab to the listbox so that I can scroll
down the list.

How do I setfocus to the listbox (I know I can change the tab order but I
thought I could move to it with a setfocus method)

Thanks

Charlie

解决方案

Did you try myListbox.Focus()?

BB

-----Original Message-----
I know I''ve done this somewhere but I cannot find any example of it in anyof my test code.

I have a form with a Listbox that is filled by a dataset it fills in varioustextboxes.

When the form first opens, I have to tab to the listbox so that I can scrolldown the list.

How do I setfocus to the listbox (I know I can change the tab order but Ithought I could move to it with a setfocus method)

Thanks

Charlie
.



Thanks BB
I had tried that but it didn''t work. Then I went back in to see if I had
done something wrong
and found that I had put the code in the wrong routine.

Thanks
Charlie
<an*******@discussions.microsoft.com> wrote in message
news:05****************************@phx.gbl...

Did you try myListbox.Focus()?

BB

-----Original Message-----
I know I''ve done this somewhere but I cannot find any


example of it in any

of my test code.

I have a form with a Listbox that is filled by a dataset


it fills in various

textboxes.

When the form first opens, I have to tab to the listbox


so that I can scroll

down the list.

How do I setfocus to the listbox (I know I can change


the tab order but I

thought I could move to it with a setfocus method)

Thanks

Charlie
.



On Thu, 04 Dec 2003 06:22:08 GMT, "Charles May"
<qu*********@hotmail.com> wrote:

Thanks BB
I had tried that but it didn''t work. Then I went back in to see if I had
done something wrong
and found that I had put the code in the wrong routine.


You should put it in the Load event of the form, so that focus is
gained as soon as the form is loaded. Make sure the control has the
tabstop property enabled


这篇关于将焦点设置为窗体上的控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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