Change Button Style in Visual Studio Express 2013

3.2k views Asked by At

The buttons in the application i've created, although set with custom images, are still Windows 7 themed (round borders, color gradience, etc). Is there a way to change them to a more windows classic or window 8 look? templates or anything that can be downloaded?

1

There are 1 answers

0
Oday Fraiwan On

Basically you are limited to the properties provided by the windows forms button class that its shape depends on the environment (operating system version) you are running.

However, you still can customize your button shape by implementing your own CustomButton class that has the Button class as its base. In that class you have to override the painting methods (and possibly other methods) and using the passed paint event args graphics object to draw your prefered shape.

public class ExampleCustomButton : Button
{
    protected override void OnPaintBackground(PaintEventArgs pevent)
    {
       using (Pen p  = new Pen(Color.Yellow))
       {
           pevent.Graphics.DrawEllipse(p,
               Left, Top, Width, Height); //for example
       }
    }

    protected override void OnPaint(PaintEventArgs pevent)
    {
       using (Pen p  = new Pen(Color.Yellow))
       {
           pevent.Graphics.DrawEllipse(p,
               Left, Top, Width, Height); //for example
       }
    }    
}

Please, do not forget to dispose IDisposable Graphics objects.

Good Luck