Create a custom control derived from
Control
or
Button
. For goodness sake, don't even think about using
PictireBox
— it is designed for very different purposes and won't give you any additional benefits over rendering right in the surface of the control, will only consume memory, CPU time and your development time without any purpose.
Instead, override
OnPaint
; in this method, use its event arguments parameter, get an instance of
System.Drawing.Graphics
and use it to render appropriate image, depending on control's status (pressed, mouse hover, default, has keyboard focus…). Change status handling control's event. When the status is changed, don't forget to trigger re-rendering of the control. This is done using
Control.Invalidate
.
See also:
How do I clear a panel from old drawing[
^].
See:
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.onpaint.aspx[
^],
http://msdn.microsoft.com/en-us/library/598t492a.aspx[
^],
http://msdn.microsoft.com/en-us/library/8dtk06x2.aspx[
^],
http://msdn.microsoft.com/en-us/library/wtzka3b5.aspx[
^].
As to the button samples, CodeProject is a good place to search in.
Watch this:
http://www.codeproject.com/search.aspx?q=Custom+button+%22VB.NET%22&doctypeid=1[
^],
http://www.codeproject.com/search.aspx?q=Custom+button+%22C%23%22&doctypeid=1[
^].
Now, pay attention: 7 articles in VB.NET, 47 in C#. Yes, to find good samples and any general help in .NET you really need to understand at least some of C#.
—SA