We help IT Professionals succeed at work.

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

2,274 Views
Last Modified: 2013-12-20
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!
Comment
Watch Question

Mohamed AbowardaSenior Software Engineer
CERTIFIED EXPERT

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

Can you please provide the code that cause the exception.
Eric BurtonSr.Programmer

Author

Commented:
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.  
Senior Software Engineer
CERTIFIED EXPERT
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Eric BurtonSr.Programmer

Author

Commented:
Solution provided.
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.