Mark T Mark T - 1 year ago 212
C# Question

Draw a single pixel on Windows Forms

I'm stuck trying to turn on a single pixel on a Windows Form.

graphics.DrawLine(Pens.Black, 50, 50, 51, 50); // draws two pixels

graphics.DrawLine(Pens.Black, 50, 50, 50, 50); // draws no pixels

The API really should have a method to set the color of one pixel, but I don't see one.

I am using C#.

Answer Source

This will set a single pixel:

e.Graphics.FillRectangle(aBrush, x, y, 1, 1);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download