Click here to Skip to main content
15,881,600 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
How do i get the position of the picture box

I have this code
C#
private void timer1_Tick(object sender, EventArgs e)
{

   if ( pictureBox1.location = Xcoord)
{
Some code
}

}
Posted
Comments
CHill60 19-Jan-13 21:24pm    
Give us a clue .. what exactly do you need?
adriancs 19-Jan-13 22:24pm    
pictureBox1.location is the position
Bruno C Soares 20-Jan-13 0:23am    
I want to get the X and Y of the picturebox
in locantion
Sergey Alexandrovich Kryukov 20-Jan-13 2:32am    
Sorry, I don't think you are ready to do UI just yet. I answered and would be very glad if my answer helps you, but it would be much more useful if you stop doing UI and graphic and go to simple console applications and learn the real basics, until you feel at least minimal confidence. Otherwise, you will waste too much time and only get frustrated.
—SA

1 solution

1) You are trying to assign, but you want a Boolean expression. Use '==', not '='; 2) C# is a case-sensitive language; there is no "location", there is "Location"; 3) Xcoord is not declared, or you simply don't show it; 5) Xcoord assume X coordinate of some numeric type, but Location is the structure with X and Y, so compare X and Y separately; 6) comparing location does not really make sense; why? you position the control, why checking it? it if is positioned with a mouse, you never do it accurately, so you really need do the hit test for some region, not one point; 7) brackets in this "code" are not balanced.

There is no situation when what you have written can be useful. You need to start over.

—SA
 
Share this 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