Link to home
Start Free TrialLog in
Avatar of Eric Burton
Eric BurtonFlag for United States of America

asked on

Receiving "Unable to cast object of type 'System.Windows.Forms.MouseEventArgs' to type 'System.Windows.Forms.KeyPressEventArgs' ERROR

I am using the Form.ShowDialog() to move from one form to another.

 When I click on a textbox on the second form I receive:

"Unable to cast object of type 'System.Windows.Forms.MouseEventArgs' to type System.Windows.Forms.KeyPressEventArgs'."

Has anyone else come across this behavior?  Thanks!
Avatar of Brad Brett
Brad Brett
Flag of United States of America image

You can't convert from 'System.Windows.Forms.MouseEventArgs' to 'System.Windows.Forms.KeyPressEventArgs'.

Can you please provide the code that cause the exception.
Avatar of Eric Burton

ASKER

Thanks for your quick response.  I figured out what my problem was. It was due to an incorrect event handler that I wrote within the code.  
ASKER CERTIFIED SOLUTION
Avatar of Brad Brett
Brad Brett
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Solution provided.