== Developing Custom Controls in .NET == == Create RoundButton == Source: //Creating Custom .NET Controls in C#//, [[http://www.ondotnet.com/pub/a/dotnet/2002/03/18/customcontrols.html]] * Create DLL project (.NET 2.0) * Add necessary References. Under Solutions Explorer, select References > Add Reference > .NET (tab), and select ''System.Windows.Forms'' and ''System.Drawing''. * Add ''OnPaint()'' code to new custom control: using System.Windows.Forms; using System.Drawing; namespace MyCustomControls { public class RoundButton : UserControl { public Color backgroundColor = Color.Blue; protected override void OnPaint(PaintEventArgs e) { Graphics graphics = e.Graphics; int penWidth = 4; Pen pen = new Pen(Color.Black, 4); int fontHeight = 10; Font font = new Font("Arial", fontHeight); SolidBrush brush = new SolidBrush(backgroundColor); graphics.FillEllipse(brush, 0, 0, Width, Height); SolidBrush textBrush = new SolidBrush(Color.Black); graphics.DrawEllipse(pen, (int) penWidth/2, (int) penWidth/2, Width - penWidth, Height - penWidth); graphics.DrawString(Text, font, textBrush, penWidth, Height / 2 - fontHeight); } } } * Compile DLL. * Open Windows Form project. * Add custom controls to ToolBox palette. Right-click on ToolBox, then Choose Items > .NET Framework Components > Browse (button). Select the custom control DLL created above. * Go to ToolBox and select the control and place it on a form in the project.