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.