Resources » Code Snippets » Winforms Controls

Create a Circle shaped Form using Regions


Posted Date: 08-Mar-2007  Last Updated:   Category: Winforms Controls    
Author: Member Level: Gold    Points: 10


This article represent code snippet for Create a Circle shaped Form using Regions in winforms controls



The “Region” property is used to apply the custom shape for the control. Here’s the example to create a form in round shape. This is very help full to create a high graphical user interface.

OnPaint event internally using the Region property, if the region property of the control is not null it will paint only the region area, its skipping other areas to paint.



public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
Form f = new Form();
f.Height = 350;
f.Width= 350;

//Creating circle path
System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath();
path.AddEllipse(0, 0, 300, 300);

//Creating the region from the circle path
f.Region = new Region(path);

f.Show();
}
}


Did you like this resource? Share it with your friends and show your love!

Responses to "Create a Circle shaped Form using Regions"

No responses found. Be the first to respond...

Feedbacks      

Post Comment:




  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:   Sign In to fill automatically.
    Email: (Will not be published, but required to validate comment)



    Type the numbers and letters shown on the left.


    Submit Article     Return to Article Index

    Subscribe to Subscribers
    Awards & Gifts
    Talk to Webmaster Tony John

    Online Members

    srikanth
    More...
    Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India