Drawing circles with System.Drawing

后端 未结 8 1148
醉酒成梦
醉酒成梦 2021-01-03 22:56

I have this code that draws a Rectangle ( Im trying to remake the MS Paint )

 case \"Rectangle\":
               if (tempDraw != null)
                {
             


        
8条回答
  •  旧巷少年郎
    2021-01-03 23:23

    if you want to draw circle on button then this code might be use full. else if you want to draw a circle on other control just change the name of control and also event. like here event button is called. if you want to draw this circle in group box call the Groupbox event. regards

        public Form1()
        {
            InitializeComponent();
    
        }
    
        private void Form1_Load(object sender, EventArgs e)
        {
            this.button1.Location = new Point(108, 12);
           // this.Paint += new PaintEventHandler(Form1_Paint);
            this.button1.Paint += new PaintEventHandler(button1_Paint);
        }
        void button1_Paint(object sender, PaintEventArgs e)
        {
            Graphics g = this.button1.CreateGraphics();
            Pen pen = new Pen(Color.Red);
            g.DrawEllipse(pen, 10, 10, 20, 20);
    
        }
    
    
    
    
    
    }
    

提交回复
热议问题