Advertisement
PedalaVasile

ez round button

Feb 13th, 2020
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.00 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Drawing.Drawing2D;
  4. using System.Windows.Forms;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Drawing;
  8.  
  9. namespace LearnToCode_v0._0
  10. {
  11.     public class RoundButton : Button
  12.     {
  13.         protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
  14.         {
  15.             GraphicsPath path = new GraphicsPath();
  16.             path.AddEllipse(0, 0, ClientSize.Width, ClientSize.Height);
  17.             this.Region = new Region(path);
  18.             e.Graphics.DrawEllipse(new Pen(Color.Blue, 1000), new Rectangle(new Point(0, 0), ClientSize));
  19.             e.Graphics.FillEllipse(new SolidBrush(BackColor), new Rectangle(new Point(0, 0), ClientSize));
  20.             e.Graphics.DrawString(Text, Font, new SolidBrush(ForeColor), new Rectangle(new Point(0, 0), ClientSize), new StringFormat() {
  21.                 LineAlignment = StringAlignment.Center,
  22.                 Alignment = StringAlignment.Center
  23.             });
  24.         }
  25.     }
  26.  
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement