$99 VS $1000+. UI Control for ASP.NET AJAX(contains chart and gridview).
RibbonBar Control for Windows Forms
Create innovative user interfaces and build Office 2007 and 2010 ribbon bar design
Home > WinForms UI Controls > User Manual > Add/Remove Tabs and Groups in C# in C#

C# Add and Remove Tabs and RibbonBar Groups

KetticRibbonBar not only allows the users to add and remove tabs and RibbonBar groups at design time, but also at run time in C# code. The tabs and RibbonBar groups adding and removing at run time in C# template projects requires the use of the appropriate collections. In this article, we are going through the process of adding and removing tabs and RibbonBar groups in C#.NET application at run time.

C# Add a Tab in KetticRibbonBar Control

When the designers of user interface of RibbonBar need to add a tab to KetticRibbonBar in C# project at run time, they need to create a new Kettic.WinForms.UI.RibbonTab object and customize the properties of the object. Then call the Add method of the KetticRibbonBar.CommandTabs collection and pass the Kettic.WinForms.UI.RibbonTab object. The C# code below shows how to achieve this.

RibbonTab tabItem1 = new RibbonTab();
tabItem1.Text = "Manage";
ketticRibbonBar1.CommandTabs.Add(tabItem1);
If the designers want to add multiple tabs at once, they need to call the AddRange method of KetticRibbonBar.CommandTabs collection by using the C# code below.

RibbonTab tabItem2 = new RibbonTab();
RibbonTab tabItem3 = new RibbonTab();
tabItem1.Text = "Write";
tabItem2.Text = "Image";
ketticRibbonBar1.CommandTabs.AddRange(new RibbonTab[] { tabItem2, tabItem3});

C# Remove a Tab from KetticRibbonBar

When the designers of RibbonBar user interface need to remove a tab, they need to call the Remove method of the CommandTabs collection and then specify the RibbonTab that will be deleted. The C# code below shows how to delete a tab from KetticRibbonBar control at runtime.

RibbonTab ribbonTab2 = (RibbonTab)ketticRibbonBar1.CommandTabs[1];
ketticRibbonBar1.CommandTabs.Remove(ribbonTab2);
The KetticRibbonBar control offers a RemoveAt method for the designers to delete a tab by index. The C# code below shows how to remove a tab by index at runtime in C# template project.

ketticRibbonBar1.CommandTabs.RemoveAt(1);

C# Add a KetticRibbonBar Group at Runtime

To add a RibbonBar group to a tab, the designers of RibbonBar UI need to create a new KetticRibbonBarGroup object and customize the properties of the object. Then call the Add method of the KetticRibbonBar.CommandTab.Items collection and pass the KetticRibbonBarGroup object to it. The C# code below shows how to create a RibbonBar group and set it.

KetticRibbonBarGroup ketticRibbonBarGroup1 = new KetticRibbonBarGroup();
ketticRibbonBarGroup1.Text = "Options";
((RibbonTab)ketticRibbonBar1.CommandTabs[0]).Items.Add(ketticRibbonBarGroup1);
When the designers want to add multiple RibbonBar groups at once, they need to call the AddRange method of KetticRibbonBar.CommandTab.Items collection by using the C# code below.

KetticRibbonBarGroup ketticRibbonBarGroup2 = new KetticRibbonBarGroup();
KetticRibbonBarGroup ketticRibbonBarGroup3 = new KetticRibbonBarGroup();
ketticRibbonBarGroup2.Text = "Options";
ketticRibbonBarGroup3.Text = "Text";
RibbonTab ribbonTab1 = (RibbonTab)ketticRibbonBar1.CommandTabs[0];
ribbonTab1.Items.AddRange(new Kettic.WinForms.KetticItem[] { ketticRibbonBarGroup2, ketticRibbonBarGroup3});

C# Remove a KetticRibbonBar Group

When the user interface designers of RibbonBar need to remove a RibbonBar group in C# project at runtime, they need to call the Remove method of the CommandTabs collection and then specify the KetticRibbonBarGroup that will be removed. The C# code below shows how to delete a RibbonBarGroup from KetticRibbonBar control at runtime.

KetticRibbonBarGroup groupToRemove = ((KetticRibbonBarGroup)(((RibbonTab) ketticRibbonBar1.CommandTabs[0]).Items[0]));
((RibbonTab)ketticRibbonBar1.CommandTabs[0]).Items.Remove(groupToRemove);
The KetticRibbonBar control offers a RemoveAt method for the interface designers of ribbon bar to remove a RibbonBar group by index. The C# code below shows how to remove a RibbonBar group by index at runtime in C# template project.

((RibbonTab)ketticRibbonBar1.CommandTabs[0]).Items.RemoveAt(1);
UI Controlsfor Windows Forms
.NET WinForms UI Overview.NET WinForms UI Features.NET WinForms UI GuideC# WinForms UI DesignVB.NET WinForms UI Design
WinForms UI Controls