Click here to Skip to main content
15,868,141 members
Articles / Productivity Apps and Services / Microsoft Office
Article

Office 2007 Button

Rate me:
Please Sign up or sign in to vote.
3.16/5 (22 votes)
10 Apr 2007GPL3 59.1K   1.7K   47   13
Button
Screenshot - ofs2007.png

Introduction

The Office2007 style button is very easy to use. Only DragDrop ToolBox.

Using the Code

C#
internal void DrawControl(Graphics e)
{
    recBounds = this.ClientRectangle;
    Rectangle m_BrushSize=new Rectangle(0, 0, 
    this.Width , this.Height / 2);

    for(int i=0;i<=40;i++)
    {
        LinearGradientBrush myLinearGradientBrush1 = 
		new System.Drawing.Drawing2D.LinearGradientBrush
		(m_BrushSize, Color.FromArgb(i,220,252,255), 
		Color.FromArgb(i,125,195,236),
        90);//top item 

        LinearGradientBrush myLinearGradientBrush=
	    new LinearGradientBrush(m_BrushSize, Color.FromArgb(i,93,174,221), 
	    Color.FromArgb(i,177,252,255),
        -90);//down item

        myLinearGradientBrush.WrapMode =System.Drawing.Drawing2D.WrapMode.TileFlipXY;
        myLinearGradientBrush1.WrapMode=System.Drawing.Drawing2D.WrapMode.TileFlipXY;

        e.FillRectangle(myLinearGradientBrush,1, this.Height/2, 
        this.Width-2 , this.Height / 2-1);//down

        e.FillRectangle(myLinearGradientBrush1,1, 1, 
        this.Width-2 , this.Height / 2);//top

        //Draw Border
        Brush brsBorder=new SolidBrush(Color.FromArgb(121,157,182));
        Pen pnsBorder=new Pen(brsBorder);

        Brush brsDot=new SolidBrush(Color.FromArgb(179,201,214));
        Pen pnsDot=new Pen(brsDot);

        e.DrawRectangle(Pens.White,this.ClientRectangle.X+1,
    	this.ClientRectangle.Y+1,this.ClientRectangle.Width-3,
    	this.ClientRectangle.Height-3);

        e.DrawLine(pnsDot,this.ClientRectangle.X,this.ClientRectangle.Y+1,
		this.ClientRectangle.X+1,this.ClientRectangle.Y+1);
        e.DrawLine(pnsDot,this.ClientRectangle.X,this.ClientRectangle.Bottom-2,
		this.ClientRectangle.X+1,this.ClientRectangle.Bottom-2);
        e.DrawLine(pnsDot,this.ClientRectangle.Right-1,this.ClientRectangle.Bottom-2,
		this.ClientRectangle.Right-2,this.ClientRectangle.Bottom-2);
        e.DrawLine(pnsDot,this.ClientRectangle.Right-1,this.ClientRectangle.Y+1,
		this.ClientRectangle.Right-2,this.ClientRectangle.Y+1);

        e.DrawLine(pnsBorder,this.ClientRectangle.X+1,this.ClientRectangle.Y,
		this.ClientRectangle.Right-2,this.ClientRectangle.Y);
        e.DrawLine(pnsBorder,this.ClientRectangle.X,this.ClientRectangle.Y+1,
		this.ClientRectangle.X,this.ClientRectangle.Bottom-2);
        e.DrawLine(pnsBorder,this.ClientRectangle.X+1,this.ClientRectangle.Bottom-1,
		this.ClientRectangle.Right-2,this.ClientRectangle.Bottom-1);
        e.DrawLine(pnsBorder,this.ClientRectangle.Right-1,this.ClientRectangle.Y+1,
		this.ClientRectangle.Right-1,this.ClientRectangle.Bottom-2);

        //////////////////////////////////////////////////////////////////end Border

        OnDrawTextAndImage(e);
        myLinearGradientBrush.Dispose();
        myLinearGradientBrush1.Dispose();
        brsBorder.Dispose();
        brsDot.Dispose();
        pnsBorder.Dispose();
        pnsDot.Dispose();
    }
}

History

  • 10th April, 2007: Initial post

License

This article, along with any associated source code and files, is licensed under The GNU General Public License (GPLv3)


Written By
Web Developer
Turkey Turkey
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
Bugcannot work in MDI form this button Pin
balagp22-Mar-12 5:57
balagp22-Mar-12 5:57 
Generalmerhaba Pin
Member 451651410-Jul-08 3:06
Member 451651410-Jul-08 3:06 
GeneralDoubt & Help Pin
AbhilashAshok22-Nov-07 21:13
AbhilashAshok22-Nov-07 21:13 
GeneralAnother Way Pin
JonFrost6-Jun-07 1:53
JonFrost6-Jun-07 1:53 
GeneralRe: Another Way Pin
KOB TURBO14-Sep-10 4:45
professionalKOB TURBO14-Sep-10 4:45 
GeneralRe: Another Way Pin
JonFrost14-Sep-10 9:56
JonFrost14-Sep-10 9:56 
GeneralA bug... Pin
Sean Yixiang Lu14-Apr-07 15:11
Sean Yixiang Lu14-Apr-07 15:11 
Generalnice control. 5 for it. Pin
Sean Yixiang Lu14-Apr-07 14:58
Sean Yixiang Lu14-Apr-07 14:58 
GeneralFormatting Pin
NormDroid10-Apr-07 21:44
professionalNormDroid10-Apr-07 21:44 
GeneralGreat control Pin
Muhammed Şahin10-Apr-07 12:06
Muhammed Şahin10-Apr-07 12:06 
GeneralRe: Great control Pin
JoseMenendez12-Apr-07 4:07
JoseMenendez12-Apr-07 4:07 
GeneralThanks! Pin
JoseMenendez10-Apr-07 9:00
JoseMenendez10-Apr-07 9:00 
GeneralRe: Thanks! Pin
dethtroll11-Apr-07 23:44
dethtroll11-Apr-07 23:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.