Chris Foley

Chris Foley

  • NA
  • 34
  • 37.3k

point.offset does NOTHING

Aug 1 2010 11:58 PM
I am working on OnPaint event to handle some data.  I need to shift some points by a dx and dy amount.  However, for a newly created Point object, the offset method does precisely nothing that I can tell.....

Point Location = new Point(myrect.X, myrect.Y);
Location.Offset(10,10);

I get no errors at all but the Point Location never changes....am I missing something?  No exceptions are generated in the debug system.

Thanks
Chris


hmmm update (maybe answering my own question)

Turns out, I do not have a variable declared called Location.  This seems to be a system keyword or obj that is a point.  I realized this when I went back to my declarations section and checked the variable names.  My point is actually GridLocation!

Private Point GridLocation;
Location = new Point(myrect.X, myrect.Y);
Location.Offset(10,10);
 
once this was changed to 

Private Point GridLocation;
GridLocation = new Point(myrect.X, myrect.Y);
GridLocation.Offset(10,10);

everything worked fine....still wondering why I did not get some warning about using something not declared!!!!

*****Solved.....I was doing this inside a form that has a Location Property!!!...now I feel like an idiot.