Hi Alan,
The Region property isn't visible in the designer. It is something that must be modified programmatically.
Ok, try this. Create a new C# Windows Forms solution. On the form, drop a button, and resize the button so that it is 50x50 pixels. Double-click the form to get the Form1_Load event. In your Form1.cs file, paste the following code over the existing code:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
Point[] pts = new Point[5];
pts[0] = new Point(0, 25);
pts[1] = new Point(25, 0);
pts[2] = new Point(50, 25);
pts[3] = new Point(25, 50);
pts[4] = new Point(0, 25);
GraphicsPath path = new GraphicsPath(pts, new byte[] { (byte)PathPointType.Line,
(byte)PathPointType.Line,
(byte)PathPointType.Line,
(byte)PathPointType.Line,
(byte)PathPointType.Line });
button1.Region = new Region(path);
}
}
You'll see that the above code modifies the region of the button by cutting off the corners. All I've done is supply it an array of points to define the shape of the button. You'll also notice that you can only click the button inside the newly chopped region.
You can achieve cool effects with more advanced sets of points (like making glassy elliptical buttons).
In reality, what you'd probably want to do if you're creating a pure owner-drawn button, is create a control that inherits from UserControl (which will be a square shape to start out with) and then use the Region property to reshape the control to suit your needs.
Then you'd handle the painting of the various button states yourself (disabled, hot tracking, clicked, etc), since the built-in button renderer is not that flexible (which you can see in the example above - all the region property did was chop off the corners, it didn't cause the renderer to re-draw the borders using that region).
Take a look on www.codeproject.com for lots of examples of owner-drawn buttons made this way.