Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
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
R3dbrnu912
Comments
CHill60 at 19-Jan-13 21:24pm
   
Give us a clue .. what exactly do you need?
adriancs at 19-Jan-13 22:24pm
   
pictureBox1.location is the position
R3dbrnu at 20-Jan-13 0:23am
   
I want to get the X and Y of the picturebox
in locantion
Sergey Alexandrovich Kryukov at 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

Rate this: bad
good
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.
 
—SA
  Permalink  

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 499
1 OriginalGriff 393
2 Maciej Los 385
3 CPallini 189
4 CHill60 180
0 OriginalGriff 6,092
1 Sergey Alexandrovich Kryukov 5,022
2 Maciej Los 3,269
3 Peter Leow 3,164
4 DamithSL 2,490


Advertise | Privacy | Mobile
Web04 | 2.8.140721.1 | Last Updated 20 Jan 2013
Copyright © CodeProject, 1999-2014
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