When I have many controls on a Form (i.e. Label, Button etc) that do almost the same thing, I often use one method to handle all the controls Click, MouseDown, MouseUp events.
But to know which of the controls throwing the event and access the properties of that control I need to cast the "sender" object to the correct type.
The thing is that I always know which type it is, I don't really have to "TryCast", "DirectCast" and check if the operation returns true. I some times use CType as well.
Dim btn as Button = CType(sender, Button)
btn.Txt = "Pushed"
I'd like to find the fastest casting method when I already know the type of the control, I know there is a Button event calling my method and like the fastest way to convert the sender object to a Button control.
Any suggestions?