Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Instant Grammar Checker - Correct all grammar errors and enhance your writing

Semrush - keyword research tool

Linux Foundation Training and Certification

Disclosure: My content contains affiliate links.

33,431 questions

43,811 answers

573 users

How to draw a square 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, 10, 10);
        }
    }
}



/*
run:



*/

 



Learn & Practice Python
with the most comprehensive set of 13 hands-on online Python courses
Start now


answered Jul 30 by avibootz
...