RibbonBar Creation in C# Windows Forms
KetticRibbonBar Control for Windows Forms is designed for the users to create Microsoft Office ribbon bar like for their applications. The RibbonBar Control can be seamlessly integrated into .NET template projects and other controls. And the users can codelessly manage all the functionalities of the Windows Forms application in a compact toolbar control. The RibbonBar Control also provides fully customizable application menu support, Office 2010 backstage view support, and nested controls. In this article, we are going to demonstrate how to create KetticRibbonBar in C#.NET projects.
How to Use KetticRibbonBar Control in Windows Forms
- To create KetticRibbonBar in C#.NET project, we need to create a KetticRibbonForm to the C#.NET project and the KetticRibbonForm will add the KetticRibbonBar control to the form automatically.
- Then we can add tabs to the KetticRibbonBar. This can be done through clicking Add New Tabâ¦, typing Edit and pressing Enter to create a new Add New Tab button to the right of Edit tab.
- Add two more TabItems to the KetticRibbonBar, and put the text of Format and Insert on the two tabs respectively.
- After adding tabs to the KetticRibbonBar, we shall add groups to the tabs. This is achieved by clicking the Format tab, and clicking the Add New Groupâ¦ button to create a new KetticRibbonBarGroup.
- When the KetticRibbonBarGroup are created, enter the Text of the group, and type Font. Repeat the complete operation to the other group and replace the Text with Paragraph. The added groups are the containers that allow the users to group controls according to the common functionality type.
- To add controls to the group, we can click the smart tag of Font group and click the link, Add Vertical Button Group. A highlight area inside of the group will display.
- Click the smart tag, KetticRibbonBarButtonGroup1, and then click Edit items link. Choose the KetticButtonElement from the drop down list to add the button.
- After creating the KetticButtonElement, we shall format the button through the smart tag menu. Choose Image from the drop down menu of DisplayStyle property and Italic from the drop down menu of ImageIndex property in Smart Tag menu. And then set the name from KetticButtonElement1 to TextItalic in the Name property.
- Now we can add ImageList to KetticRibbonBar by drag and drop the ImageList control to the form. Open the Images Collection Editor, add images to represent Italic text and Bold text to the ImageList. Locate the ImageList property in KetticRibbonBar, click the drop down arrow, and select ImageList1 from the drop down list.
- Then, add a RichTextBox by drag and drop a RichTextBox control to the form. Open the Smart Tag of the RichTextBox control and execute the Dock in parent container.
- After adding the RichTextBox to the RibbonBar control, we can add the C# code below to make the text of the buttons bold or italic.
- Link the Bold and Italic buttons to their event handler C# code. This is achieved by clicking the Bold button and selecting the Event code icon in the Properties window. Locate the Click Action event and choose the TextBold_Click from the drop down list. Set Click Action of Italic button to TextItalic_Click.
- Run the project and add text to the text area to check the result.