Please note that this is not my work, and comes from this tutorial
public class RoundedPanel : Panel
{
public int Radius { get; set; }
public Color BorderColor { get; set; }
public Color FillColor { get; set; }
public bool Fill { get; set; }
public bool AntiAlias { get; set; }
public RoundedPanel()
: base()
{
BackColor = Color.White;
FillColor = Color.Transparent;
Fill = false;
AntiAlias = true;
DoubleBuffered = true;
Radius = 18;
}
protected override void OnPaint(PaintEventArgs e)
{
GraphicsPath path = RoundedRectangle.Create(0, 0, Width - 1, Height - 1, Radius);
e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
e.Graphics.DrawPath(new Pen(BorderColor, 1f), path);
if (Fill)
{
e.Graphics.FillPath(new SolidBrush(FillColor), path);
}
}
}
Panel Control with Rounder Corners
ReplyDeleteHi,
ReplyDeleteYou have used this code-
RoundedRectangle.Create(0, 0, Width - 1, Height - 1, Radius);
where this RoundedRectangle class is defined?
Oops, looks like I omitted that. Check out the link in the post-description to a tutorial where i originally found the source for this functionality
ReplyDeletecan you copy the RoundedRectalgle
Deleteclass code cause the link won't work
not working, and with http://web.archive.org/web/20150427121927/http://tech.pro/tutorial/656/csharp-creating-rounded-rectangles-using-a-graphics-path also
ReplyDelete