Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vb.net 使用反射确定控件是否支持事件_Vb.net_Reflection - Fatal编程技术网

Vb.net 使用反射确定控件是否支持事件

Vb.net 使用反射确定控件是否支持事件,vb.net,reflection,Vb.net,Reflection,要避免try-catch块,是否有一种方法可以确定控件是否支持指定的事件而不使用try-catch块 Dim d As [Delegate] = [Delegate].CreateDelegate(eventHandler.EventHandlerType, _ Me, _

要避免try-catch块,是否有一种方法可以确定控件是否支持指定的事件而不使用try-catch块

Dim d As [Delegate] = [Delegate].CreateDelegate(eventHandler.EventHandlerType, _
                                                                Me, _
                                                                "OnControlValueChanged") '<<
d作为[Delegate]=[Delegate].CreateDelegate(eventHandler.EventHandlerType_
我,_
“OnControlValueChanged”)”使用反射:

Dim events As System.Reflection.EventInfo() = GetType(Control).GetEvents()
For Each someEvent As System.Reflection.EventInfo In events
    If someEvent.Name = "OnControlValueChanged" Then
        'Do what you need to do
    End If
Next