Click here to Skip to main content
13,147,183 members (29,326 online)
Rate this:
Please Sign up or sign in to vote.
See more:
How do i get the position of the picture box

I have this code
private void timer1_Tick(object sender, EventArgs e)
   if ( pictureBox1.location = Xcoord)
Some code
Posted 19-Jan-13 15:11pm
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
R3dbrnu 20-Jan-13 0:23am
I want to get the X and Y of the picturebox
in locantion
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.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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.


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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web02 | 2.8.170915.1 | Last Updated 20 Jan 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100