SoFunction
Updated on 2025-03-07

C# non-rectangular form implementation method

This article describes the implementation method of C# non-rectangular form. Share it for your reference. The specific implementation method is as follows:

using System;
using ;
using ;
using ;
using ;
using ;
using ;
using .Drawing2D;
namespace WindowsApplication1
{
  public partial class Form3 : Form
  {
    Point downPoint = ;
    public Form3()
    {
      InitializeComponent();
    }
    void Set()
    {
      Rectangle rect = ;
      using (GraphicsPath path = new GraphicsPath())
      {
        (rect);
         = new Region(path);
      }
    }
    private void Form3_Load(object sender, EventArgs e)
    {
      Set();
    }
    private void Form3_MouseDown(object sender, MouseEventArgs e)
    {
      if ( != ) return;
      downPoint = new Point(, );
    }
    private void Form3_MouseMove(object sender, MouseEventArgs e)
    {
      if (downPoint == ) return;
      Point location = new Point( +  - ,  +  - );
       = location;
    }
    private void Form3_MouseUp(object sender, MouseEventArgs e)
    {
      if ( != ) return;
      downPoint = ;
    }
  }
}

I hope this article will be helpful to everyone's C# programming.