本文介绍了当焦点从一个控件转移到另一个控件时,是否有任何事件触发?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我在表格中有100个控件。我想运行一些代码,当焦点从一个控件更改为vb.net形式的另一个控件。是否有任何事件?

Hi,

I am having 100''s of controls in a form. I want to run some code, when focus changed from one control to another control in vb.net form. Is there any event?

推荐答案


Private Sub LostFocus(ByVal sender as System.Object, e As EventArgs) Handles _
Control1.LostFocus, Control2.LostFocus, Control3.LostFocus, Control4.LostFocus, _
Control5.LostFocus, Control6.LostFocus, Control7.LostFocus, Control8.LostFocus, _
Control9.LostFocus, Control10.LostFocus

'Now Use sender Parameter to Identify Which Control Lost it's Focus
Select Case sender.Name
case Control1.Name
    ' Write Code
case Control2.Name
    ' Write Code
case Control3.Name
    ' Write Code
case Control4.Name
    ' Write Code
case Control5.Name
    ' Write Code
case Control6.Name
    ' Write Code
case Control7.Name
    ' Write Code
case Control8.Name
    ' Write Code
case Control9.Name
    ' Write Code
case Control10.Name
    ' Write Code
case Else
    ' Write Code Here if Necessary

End Select

End Sub



这篇关于当焦点从一个控件转移到另一个控件时,是否有任何事件触发?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-12 21:22