Cast sender object in event handler using GetType().Name
You never have to cast. I used to think the same way when I started, this ‘pattern’ is incorrect, and not really logical. Your best bet is to use something like: if (sender is TextBox) { TextBox tb = (TextBox)sender; } else if (sender is RichTextBox) { RichTextBox rtb = (RichTextBox)sender; } else { // … Read more