HI
try using following code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
using System.Drawing.Drawing2D;
namespace WinForms4OpacityControl
{
public class CircularPanel : Panel
{
public CircularPanel()
{
this.BackColor = Color.AliceBlue; // set an image.
this.Size = new Size(50,50);
}
protected override void OnPaint(PaintEventArgs e)
{
GraphicsPath buttonPath = new GraphicsPath();
// Set a new rectangle to the same size as the button's
// ClientRectangle property.
Rectangle newRectangle = this.ClientRectangle;
// Decrease the size of the rectangle.
newRectangle.Inflate(-10, -10);
// Draw the button's border.
e.Graphics.DrawEllipse(System.Drawing.Pens.Black, newRectangle);
// Increase the size of the rectangle to include the border.
newRectangle.Inflate(2, 2);
// Create a circle within the new rectangle.
buttonPath.AddEllipse(newRectangle);
// Set the button's Region property to the newly created
// circle region.
this.Region = new System.Drawing.Region(buttonPath);
base.OnPaint(e);
}
}
}
==========================================================
public partial class Form2 : Form
{
CircularPanel circularPanel1;
public Form2()
{
InitializeComponent();
}
private void AddCircularPanel()
{
this.circularPanel1 = new WinForms4OpacityControl.CircularPanel();
this.SuspendLayout();
//
// circularPanel1
//
this.circularPanel1.BackColor = System.Drawing.Color.AliceBlue;
this.circularPanel1.Location = new System.Drawing.Point(129, 103);
this.circularPanel1.Name = "circularPanel1";
this.circularPanel1.Size = new System.Drawing.Size(50,50);
this.circularPanel1.TabIndex = 0;
//
this.Controls.Add(this.circularPanel1);
this.ResumeLayout(false);
} /// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.SuspendLayout();
//
// Form2
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(292, 273);
this.Name = "Form2";
this.Text = "Form2";
this.Load += new System.EventHandler(this.Form2_Load);
this.ResumeLayout(false);
}
#endregion
private void Form2_Load(object sender, EventArgs e)
{
AddCircularPanel();
return;
}
}