如何将处理多个事件句柄的VB.NET Private Sub转换为C#? [英] How to convert VB.NET Private Sub that handle multiple event handles to C# ?

查看:86
本文介绍了如何将处理多个事件句柄的VB.NET Private Sub转换为C#?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我想将这两个方法转换为C#,但我不知道如何保留事件句柄以保持这两个方法在C#中工作。



VB.NET代码:



Hi,

I want to convert these two method into C# but I don't know how to keep the event handles to keep these two method working in C#.

VB.NET Code:

Private Sub SetLAO(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtCL_VL_LA.Enter, txtCL_FN_LA.Enter, txtCL_LN_LA.Enter
        vhd.SetLao(2)
    End Sub

    Private Sub SetENG(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtCL_VL_LA.Leave, txtCL_FN_LA.Leave, txtCL_LN_LA.Leave
        vhd.SetLao(0)
    End Sub







我试图像这样转换:






I tried to convert like this:

private void SetLAO(System.Object sender, System.EventArgs e)
        {
            vhd.SetLao(2);
        }

        private void SetENG(System.Object sender, System.EventArgs e)
        {
            vhd.SetLao(0);
        }





但似乎没有每个文本框的事件句柄

所以请帮助!



提前谢谢



but it seem no event handles for each textbox
So please help!

Thank you in advance

推荐答案

在InitializeComponent()方法中(在.designer.cs文件中), add:

In InitializeComponent() method (in .designer.cs file), add:
txtCL_VL_LA.Enter += SetLAO;
txtCL_FN_LA.Enter += SetLAO;
txtCL_LN_LA.Enter += SetLAO;
txtCL_VL_LA.Leave += SetENG;
txtCL_FN_LA.Leave += SetENG;
txtCL_LN_LA.Leave += SetENG;



您可能必须小心将这些行放在代码文件中的位置。观察该文件的结构并确定每行的放置位置。


You may have to be careful as to where you put these lines in the code file. Observe the structure of this file and decide where to put each line.


这篇关于如何将处理多个事件句柄的VB.NET Private Sub转换为C#?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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