按下Enter键可将焦点移至用户控制 [英] Move focus for usercontrol on enter key down

查看:108
本文介绍了按下Enter键可将焦点移至用户控制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当输入是按下键时(如使用标签页),如何将焦点从一个用户控件移到另一个用户控件?
用户控件包含文本框和标签,为网格声明了事件...
此代码适用于控件,但不适用于用户控件....
对不起,我的英语不好...

How to move focus from one to another user control when enter is keydown like with tab?
User control contains textbox and label, event is declared for grid...
This code work for Controls but no work for user control....
Sorry for my bad English...

Private Sub drzac_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Input.KeyEventArgs)
       Dim tb As New Control
       tb = e.Source
       If e.Key = Key.Enter Then
           tb.MoveFocus(New TraversalRequest(FocusNavigationDirection.Next))
       End If
   End Sub

推荐答案

您的用户控件是一个单独的控件,您需要在它获得焦点时进行处理,然后集中处理要在该控件内关注的控件.
Your user control is a single control, you need to handle when it gets the focus and then focus on the control you want to focus on within that control.


解决,谢谢,您是正确的:)
Resolve, thank you, you were right :)


这篇关于按下Enter键可将焦点移至用户控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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