2、通过Reflection查看,代码如下:
Public Function GetControlByName(ByVal Name As String) As Control
'now, why would I put a "_" in front of the name?
Dim info As System.Reflection.FieldInfo = Me.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
Dim o As Object = info.GetValue(Me)
Return o
End Function
'now, why would I put a "_" in front of the name?
Dim info As System.Reflection.FieldInfo = Me.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
Dim o As Object = info.GetValue(Me)
Return o
End Function