如何在VB.net中更改控件焦点 [英] How to change control focus in VB.net

查看:565
本文介绍了如何在VB.net中更改控件焦点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是VB.net的新手
我正在开发应用程序屏幕.在该屏幕上,我有许多控件,例如文本框,下拉菜单等.对于文本框,我设置了一些字符限制.我的要求是,当我从下拉菜单(使用鼠标或键盘)中选择一个项目时,在此下拉菜单之后,焦点应转到下一个控件.当我在文本框中输入某个值时,达到字符限制后,焦点应自动位于下一个控件上.在VB.net中怎么可能.
是否可以使用Java脚本?

感谢您的帮助
___ RX23 ___

I am new to VB.net
I am developing an application screen. In that screen I have many controls like text box, drop down etc. For text boxes some charcter limit I have set. My requirement is that when i select an item from drop down(either using mouse or key board), the focus should go to next control after this drop down. When i enter some value in the text box, after reaching the charcater limit, the focus should automatically be on the next control. How is this possible in VB.net.
Is it possible using java script?

Thanks for the help
___RX23___

推荐答案



在dropdownbox1_SelectionChanged事件和字符限制功能中,使用下面的代码

Hi,

In dropdownbox1_SelectionChanged event and the character limitation function, use the below code

If controltobefocused.CanFocus Then
controltobefocused.Focus()
End If


Hi Rx232,
该方法中将有一个类似dropdownlist_selectedIndexChanged()的方法,您可以将焦点分配给下一个控件.
Hi Rx232,
There will be an method like dropdownlist_selectedIndexChanged() within the method you can assign the focus to the next control.
protected void ddllist_SelectedIndexChanged(object sender, EventArgs e)
    {
        //write some code to focus on next control
   }



问候,
Bluesathish



Regards,
Bluesathish


使用js
use js
function kydown()
{ 
if(event.keyCode==13)
{
event.keyCode=9;
return;
}
}





<body   önkeydown="return kydown();">
</body>



不要忘记评价它是否对您有用



dont forget to rate is it is usefull for you


这篇关于如何在VB.net中更改控件焦点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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