How to draw a pixel with a specific color on a Window using WinForms in C#

1 Answer

0 votes
namespace WinFormsApp1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Brush aBrush = (Brush)Brushes.Red;
            Graphics g = this.CreateGraphics();

            int x = 400;
            int y = 300;

            g.FillRectangle(aBrush, x, y, 1, 1);
        }
    }
}



/*
run:



*/

 



answered Jul 30, 2024 by avibootz
...