Content:

Note: There are some more bugs fix at the Discussions Section shared by other user.


There is another ribbon made by kcarbis based on this ribbon.
See discussion >> Office 2010 Style Orb, Tooltips, and a Minimize Feature
Website: http://www.staffinder.net/carbisoft/
According to kcarbis, some bugs in this ribbon were fixed and features are extended.
The project has started here: http://officeribbon.codeplex.com/

How to Use This Ribbon Control

1. Download the Ribbon Source and obtain System.Windows.Forms.Ribbon.dll at Download page of this project.

Note: To develop with .NET Framework 3.5 & 4.0.
The original develop platform of this ribbon is .NET Framework 2.0. To use this ribbon in .NET Framework 3.5 or 4.0, all you have to do is convert the source code of this ribbon into .NET Framework 3.5 or 4.0. create a new blank class of .NET Framework 4.0. Add all cs files from source project into the blank class and reference of System.Design, System.Windows.Forms and System.Drawing. Compile it.
See: How to Obtain DLL for .NET Framework 3.5 & 4.0

2. Create a blank WinForm Project.

01.png

3. Adding Ribbon into Form.
There are 2 methods to add the Ribbon into the Form.

1st method: Using Code to add it.
2nd method: Drag and Drop

1st Method: Using Code to add it.

3.1.1. Add a Reference of System.Windows.Forms.Ribbon.dll to your project.
3.1.2. Right click on Reference at the Solution Explorer, choose Add.

02.png

3.1.3. Locate the System.Windows.Forms.Ribbon.dll.

03.png

3.1.4. Open the designer of the Main Form. In this example, Form1.Designer.cs.

04.png

3.1.5. This is the initial code for Form1.Designer.cs:

namespace WindowsFormsApplication1
{
    partial class Form1
    {
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Windows Form Designer generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.components = new System.ComponentModel.Container();
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.Text = "Form1";
        }

        #endregion
    }
}


3.1.6. Add three lines of code into Form1.Designer.cs.
private System.Windows.Forms.Ribbon ribbon1;
this.ribbon1 = new System.Windows.Forms.Ribbon();
this.Controls.Add(this.ribbon1); 

05.png

3.1.7. Save and close Form1.Designer.cs.

3.1.8. Double click and open Form1.cs, and now the Ribbon control is added into the main form.

06.png

07.png


2nd Method: Drag and Drop

3.2. 2nd Method: Drag and Drop

3.2.1. This is more simpler way to add the ribbon into the form. Just simply create a new tab at Toolbox. 3.2.2. Drag and drop the DLL into the new tab.
3.2.3. Click on any area of Toolbox. Right click > Add Tab.

a1.png

3.2.4. Give the new tab a name.

a2.png

3.2.5. Drag the DLL into the new tab area.

a3.png

3.2.6. Drag the Ribbon into the Form. Thats it.

a4.png

And this will automatically add a reference of System.Windows.Forms.Ribbon for you.


4. Click on the Ribbon and Click Add Tab.

08.png

5. Click on the newly added RibbonTab, then click Add Panel.

09.png

6. Click on the newly added RibbonPanel, go to Properties. A set of available controls that can be added to the RibbonPanel.

10.png

7. Try add some buttons into the RibbonPanel.

8. Click on the RibbonButtons, go to Properties. Lets try to change the image and the label text of the button.

13.png

9. This is how your ribbon looks like now.
10. Now, create the click event for the buttons. Click on the RibbonButton, go to Properties, modify the Name of the button.

11.png

11. Open the code of Form1.cs.

12. This is what we have initially:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
    }
}



13. Add the Button Clicked event for the RibbonButton.
public Form1()
{
    InitializeComponent();
    cmdNew.Click += new EventHandler(cmdNew_Click);
    cmdSave.Click += new EventHandler(cmdSave_Click);
}

void cmdNew_Click(object sender, EventArgs e)
{
    MessageBox.Show("Button \"New\" Clicked.");
}

void cmdSave_Click(object sender, EventArgs e)
{
    MessageBox.Show("Button \"Save\" Clicked.");
}

14. Press F5 to run the application. Done.

12.png

15. You might want to inherit your Main Form into a RibbonForm to have extra feature. Such as:
Note: Inherit the Main Form to RibbonForm will have some compatible problems with some of System.Windows.Forms controls.

14.png

16. At the code of Form1.cs, change this line:
public partial class Form1 : Form

to this line:
public partial class Form1 : RibbonForm

Here is the sample project explain above:
Download: RibbonSample.zip

Cautious While Using With Visual Studio 2010

ALWAYS SAVE AND CLOSE straight away after you have finished designing the GUI editing of Main Form (The form that contains the ribbon control).

Don't Run (Press F5) The Application while the Main Form is open in Visual Studio 2010.

Or else, you might experience that the ribbon control has disappeared. You will end up redesigning/redraw the ribbon and reconnect all the events that associated with the ribbon.

Last edited Apr 29, 2012 at 1:32 AM by adriancs, version 40

Comments

jcmatoso Aug 23, 2012 at 11:38 AM 
Does it work with Visual Basic Express rel.8 or 10?
If so where iss the code?

João