Copy this text, then add a class to your project and replace text in class with this method. Once you have done this rebuild your application and open toolbox and you will have a custom button control called myButton that should show towards the top of your tool box drag and drop the control onto your form and you should see the control on your form.
using System;
using System.IO;
using System.Drawing;
using System.Windows.Forms;
class myButton : Panel
{
public myButton()
{
this.Size = new Size(75, 23);
this.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
}
private Image buttonImage
{
get
{
string base64string = "iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAA1RJREFUeNq0VetLVFEQn3P35aobahpEUtkXQSw2A+1BEPTVPgRiCqsSQn71TwmCyCAMM5IQIZLwSxBIpNGGhRBEYmUPRFvfu3v3nkcz99y9u3dd0Q0aGC7nnDm/md/MnLlMKQWMMSDp+6iCYMAtXHbg8gIeBWEfca5m0PYNKBiXAu4/irIMbdrYWQexuDoGDCZxP1oeBgiX4WU4gDhGqTTATpJQYU4JaH/cyn66DnrmIMjTKo7WzbWH0UaQd60HZADMB2CgrqziQqp5X4idG22BjJ8O0+tygDGjua4WgKcQWNqRgKa5P7jNAtUwAGoi6GSFNfO0HMCdOwadWztmTyiAX8yc4BgAMhCOSrm3ujakeI+TIgZhZRCTsG0GCvzRoF8bQZHUBDGMwUaAxkN63T+7BxuhmRAWMH+U9m0GkosAgUsneo9ipD6WAyd50LbbLss8iyM4D7gOOPIkqtyhKfJSRBc3sS69096Ihy8W2BXe5wJyDITcHXkRjb3yOhm5XNxOs5Hg1kDggjazPX29AaDzFBxIRq8AdL/07lENhePAYSA8ERwUPCtPrurW9jLJS5HgmgEpC8A/iVEGLobWXQyoDgoMnD4Ty6WB98azDJSjwmWga2AJ7RGbmZs+GF8EeLasnz+1nLWND2cT7UwFT68xCPpy4LF3+jy9JvJqIF0GtgMpla46Okgl8JsoHunzDm/+umewLXcI3PJUmBxIje+8ZMwLxwbGeZQ3YLzy4kbIs+58TSMGwFwzCzpIaidGIFcDI1jB8eVha3FMCXdzmFV/ZQgmlnIgHfjozA0c0atJj53gln2fWxY2S3kqlyJIf05nWFPIr5y54mVCdRj5hD2/gMHRa02Sg+2ikZOYmH9lmFjJCu0g+evLFDvR2hRSKZBW2naZP49TifW9W6hgMhqBMsiEwpD89nYKoFWnaOFe/11ubi5uGGEIVFUTPbfw+yrZodIduksYhEWYdozOL9OoOd/Vfvzm0G1f+FBDZSVAJFLaW9jaAtjGrInU5uL34YHBxMzYJGJLlvfTDwWqjradHBjtCtefvuSP1J0pxQHf/jOfWvow/XUoNmat/55teajMeF+OgZtC1HrUI6jVJU4LKhTNgB9nh7HiCPk+6+B/yl8BBgDnEVPWrXYOEgAAAABJRU5ErkJggg==";
byte[] base64byte = Convert.FromBase64String(base64string);
MemoryStream base64stream = new MemoryStream(base64byte);
return Image.FromStream(base64stream);
}
}
protected override void OnMouseDown(MouseEventArgs e)
{
base.OnMouseDown(e);
this.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
}
protected override void OnMouseUp(MouseEventArgs e)
{
base.OnMouseUp(e);
this.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
DrawButtonImage(e);
DrawButtonText(e);
}
private void DrawButtonText(PaintEventArgs e)
{
e.Graphics.DrawString("button1",this.Font,Brushes.Black,new PointF(25,3));
}
private void DrawButtonImage(PaintEventArgs e)
{
e.Graphics.DrawImage(buttonImage, 0, 0, 20, 20);
}
}