Hi @NachitoMax ,
You can take a look at the following code.
Public Class Validate
Public Sub New()
End Sub
Friend Function Validate(ByVal _control As Control) As String
If TypeOf _control Is TextBox Then
'...
ElseIf TypeOf _control Is Label Then
'...
ElseIf TypeOf _control Is ComboBox Then
Dim prop As PropertyInfo = _control.GetType.GetProperty("DropDownStyle")
Dim v As ComboBoxStyle = CType(prop.GetValue(_control), ComboBoxStyle)
prop.SetValue(_control, ComboBoxStyle.DropDownList)
End If
'...
End Function
End Class
It can help you get and set the value of the property dynamically according to the type of control at run time
Hope it could be helpful.
Best Regards,
Xingyu Zhao
*
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.