Use Dotnetbar to create an office07 style form

Source: Internet
Author: User

Step 1:

Open vs2005 and create a project.

Step 2:

Copy DevComponents. DotNetBar2.dll to the debug directory (not required, of course ).

Step 3:

Add the controls in dotnetbar to the vs2005 toolbox. Specifically, click "select toolbox item" under "Tools" in the menu on vs, and then "Browse", select DevComponents copied to the debug directory. dotNetBar2.dll, OK, so some controls in dotnetbar are added in the toolbox.

Step 4:

First, drag a RibbonControl control to the main form. Then we can see that there is a c # form border outside, and the office style is inside. This is the legend of the last three, haha, next we will convert it into a pure office style form.

Step 5:

Let Form1 inherit DevComponents. DotNetBar. Office2007RibbonForm

That is, it becomes "public partial class Form1: DevComponents. DotNetBar. Office2007RibbonForm ".

Here, you can see the desired style.

The following steps Add the transform Style Function

Step 6:

Right-click the RibbonControl control and select Create Button to add a Button buttonItemStyle. Change the ItemAlignment attribute of the Button to Far to hide it to the rightmost.

Step 7

Right-click the added button and select Add button. Repeat this action. Add three child buttons Under buttonitemstyle (I name it buttonitemblue, buttonitemblack, buttonitemsilver ), set text to "office 07 blue", "office 07 black", and "office 07 silver" respectively ".

Step 8

Add a variable for form1

Private devcomponents. dotnetbar. Rendering. eoffice2007colorscheme m_scheme = devcomponents. dotnetbar. Rendering. eoffice2007colorscheme. vistaglass;

Step 9

Drag a command control to the form, View Properties-events, and add its execute event commandintoexecuted. The code in the event is as follows:Private void commandincluexecuted (Object sender, eventargs e) {devcomponents. dotnetbar. icommandsource source = sender as devcomponents. dotnetbar. icommandsource; If (source. commandparameter is string) {devcomponents. dotnetbar. rendering. eoffice2007colorscheme colorscheme = (devcomponents. dotnetbar. rendering. eoffice2007colorscheme) enum. parse (typeof (devcomponents. dotnetbar. rendering. eoffice2007colorscheme), source. commandparameter. tostring (); ribboncontrol1.office2007colortable = colorscheme;} else if (source. commandparameter is color) {devcomponents. dotnetbar. ribbonpredefinedcolorschemes. changeoffice2007colortable (this, m_scheme, (color) source. commandparameter);} This. invalidate ();}

Step 10

Didn't I add three buttons just now? Now I have set attributes for the three buttons. Check the attributes of buttonitemblue and find that the command attribute is missing? Select the command1 command you just added and set its commandparameter attribute to "blue". Repeat this step to set the command attribute to command1 for buttonitemblack and buttonitemsilver, commandparameter is "black" and "silver ".

-- Run. Is the result displayed?

-- See, oh.

 

Next, you can add buttons and other controls.

 

Let's see:

The image upload function is disabled.

 

Dormitory buddies despise me and say that the traffic is too small.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.