Click here to Skip to main content
15,888,030 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, I want to store my controls XY position, so I used an object to store that XY postion values. The object variable is taking that value's but when I am assiging that object variable to control location it's showing some error like this:

Specified cast is not valid.

So, please tell me some solution for this
Posted
Updated 1-Nov-10 21:37pm
v2
Comments
JF2015 2-Nov-10 3:37am    
We can't help you without some code snippets from your side!
qontary 2-Nov-10 3:40am    
It would be easier for others to understand if you include the code that caused the error.
Arindam Tewary 2-Nov-10 3:48am    
Seeing the error message it seems that you might need to use appropriate method of "Convert" class (like Convert.ToInt32(),Convert..... ) because it is a casting error. Otherwise post some code part that might help people to help you.

1 solution

If you created an object to store the (X,Y) position of your controls, the best thing to do is: Throw it away, and use the Point class instead.

You cannot cast from a user defined class to a Point - which is what the compiler is complaining about.
 
Share this answer
 
Comments
Dalek Dave 2-Nov-10 4:36am    
Good Answer.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900