Question

This may appear a silly question to some but it is giving me a headache! I know how to draw a horizontal line in my program like so:

 e.Graphics.DrawLine(new Pen(Color.Gray, 1), new Point(22, 1100), new Point(782, 1100));

But for some reason, I cannot seem to get around displaying a simple vertical line. This is what it currently looks like: (I'm looking at it in Preview using PrintDocument.

d

I know it is going to be a real simple answer and I have researched.

Était-ce utile?

La solution

I may be completely missing the point here, but presumably the new Point(X,Y) lines there are the coordinates of the line?

That being the case, surely what you want is something like ...

e.Graphics.DrawLine(new Pen(Color.Gray, 1), new Point(22, 10), new Point(22, 1100));

where you keep the X position the same in both points but change the Y?

Autres conseils

Yay! I have found a solution:

e.Graphics.DrawLine(new Pen(Brushes.Orange,1), 400, 400, 400, 100);
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top