Click here to Skip to main content
15,890,932 members
Articles / Programming Languages / C#
Tip/Trick

Heart shaped Form in C# 2.0

Rate me:
Please Sign up or sign in to vote.
4.73/5 (11 votes)
29 Mar 2011CPOL 27.6K   11   2
Here is how we can make a Form in Heart shape.

The Form should have a minimum size with the followinhg dimensions: width=356, height=317.

In the Load event of the Form, write the following code:
C#
private void Form1_Load(object sender, EventArgs e)
{
    System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath();
    path.AddArc(70, 10, 150, 150, 135, 195);
    path.AddArc(200, 10, 150, 150, 210, 195);
    path.AddLine(92, 139, 210, 270);
    path.AddLine(327, 139, 210, 270);
    path.AddLine(327, 139, 92, 139);
    this.Region = new Region(path);
}

Just debug it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Comments and Discussions

 
GeneralGood one. Have 5 Pin
Toniyo Jackson6-Apr-11 21:34
Toniyo Jackson6-Apr-11 21:34 
General[My vote of 2] Best article I've ever seen! Pin
Jan Arjen Kraak4-Apr-11 20:57
Jan Arjen Kraak4-Apr-11 20:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.