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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Selva GanapathyPosted Apr 10, 2014, 2:44 AM
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
Jignesh TrivediPosted Apr 8, 2014, 12:33 AM
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
Jayant KumarPosted Apr 8, 2014, 12:28 AM
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);
}
}
}