Imports System.Windows.Forms
Public Class ReflectionInfo
Public Shared Function GetControlByName(ByVal Name As String, _
ByVal CurrentForm As Form) As Control
Dim info As System.Reflection.FieldInfo = _
CurrentForm.GetType().GetField("_" & Name, _
System.Reflection.BindingFlags.NonPublic Or _
System.Reflection.BindingFlags.Instance Or _
System.Reflection.BindingFlags.Public Or _
System.Reflection.BindingFlags.IgnoreCase)
If info Is Nothing Then
Return Nothing
Else
Return CType(info.GetValue(CurrentForm), Control)
End If
End Function
End Class