I want to add a handler to a control that i find by its name. The Problem is that it is not possible to Dim an control from a Button or RadioButton or something like this...
Dim control As Control = FindName(MyObject.Name.ToString)
AddHandler control.MouseEnter, Sub()
Try
Dim Tooltip As New ToolTip()
Tooltip.SetToolTip(control, control.Name.ToString)
Catch
End Try
End Sub
In the code i could dim control as Button but then e.g. RadioButtons would not work. And I do not want to have a code that always checks for the ObjectType and then go into an if part like
If TypeName(MyObject).ToString = "Button" then
...
else if TypeName(MyObject).ToString = "Label" then
...
else if TypeName(MyObject).ToString = "RadioButton" then
...
End If
Is there a better solution then doing it this way?
E.g. something like
Dim Control as TypeName(MyObject).ToString = FindName(MyObject.Name.ToString)