Hi,
I want to shape my main form into circle shape, Please let me know how can I do that?
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Selva GanapathyRank #560 · 4.3K reputationPosted Apr 9, 2014, 10:44 PM EDT
You can use region or TransparencyKey
namespace Circle_Form
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
// Using Region
Form form = new Form();
System.Drawing.Drawing2D.GraphicsPath graphicsPath = new System.Drawing.Drawing2D.GraphicsPath();
graphicsPath.AddEllipse(new Rectangle(100, 100, 200, 200));
form.Region = new Region(graphicsPath);
form.Show();
//Using TransparencyKey
this.TransparencyKey = Color.Blue;
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
var backColor = this.BackColor ;
e.Graphics.FillRectangle(Brushes.Blue, new Rectangle(0,0,this.Width ,this.Height));
e.Graphics.FillEllipse(Brushes.Orange, new Rectangle(100, 100, 200, 200));
}
}
}
Regards,
Selva Ganapathy K
Jayant Kumar12 reputationPosted Apr 7, 2014, 8:28 PM EDT
Below is the source code and project has been attached Please download and run
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace RoundedCorner
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
GraphicsPath path = new GraphicsPath();
path.AddEllipse(new Rectangle(0, 0, 300, 300));
Region = new Region(path);
}
}
}
Jignesh TrivediRank #16 · 50.3K reputationPosted Apr 7, 2014, 8:33 PM EDT
hi,
Please refer below link it might help you.
http://www.codeproject.com/Articles/8056/Creating-Custom-Shaped-Windows-Forms-in-NET
http://www.codeproject.com/Articles/17874/Custom-shaped-form-with-a-drop-down-in-C