Piotrekk wrote:
Graphics pea = e.Graphics;
Point [] ptTable = { pictureBox1.Location , new
Point(pictureBox1.Location.X +
pictureBox1.Width,pictureBox1.Location.Y + pictureBox1.Height) };
pea.DrawLines(new Pen(Brushes.Black, 1), ptTable);
Line is simply drawn not from the 0,0 where control has it's
origin....
Does anyone know why this happens?
In what class does your code exist? What is that class's relationship
to the pictureBox1 instance?
And is there a good reason you're using DrawLines() instead of DrawLine()?
Finally, you are leaking pens. Not that it has anything to do with your
question, but you need to dispose Pen objects if you create them. A
better approach would be to simply use the built-in black pen
(Pens.Black), since you aren't using a non-default size for the pen.
Undoubtedly, the line is getting drawn exactly where you are telling
DrawLines() to draw it. The only question is why are you mistaken about
what you are telling DrawLines() to do. I suspect the answer has
something to do with how the Location property of the pictureBox1 class
relates to the control in which you're actually doing the drawing, but
you didn't post enough code to adequately show that.
If you post a concise-but-complete example of code that reliably
reproduces the problem, you may get more specific advice.
Pete