Articles in this section
Category / Section

How to merge RibbonPanelContainercontrol from child form in WinForms RibbonControlAdv?

1 min read

Creating RibbonPanelMergeContainer

In RibbonControlAdv, it is possible to merge the RibbonPanel of the child form to the ribbon control of Main Form by using “RibbonPanelMergeContainer”. This documentation will guide to merge the RibbonPanel of the Child Form to the RibbonControlAdv in Parent Form and you can also activate the recently added tab by using SelectedTab property in RibbonControlAdv. The following code demonstrates the same.

C#

/// <summary>
/// For MDIChildForm is merged to Parent Form.
/// </summary>
Form2 form = new Form2();
form.MdiParent = this;
form.Text = "Form" + count;
form.Show();
 
// To Select recently added MDIChildForm
foreach (ToolStripTabItem TabItem in this.ribbonControlAdv1.Header.MainItems)
{
  if((TabItem as ToolStripTabItem).Panel != null
&& (TabItem as ToolStripTabItem).Panel is RibbonPanelMergeContainer)
  {
    this.ribbonControlAdv1.SelectedTab = TabItem;
    break;
  }
}

VB

''' <summary>
''' For MDIChildForm is merged to Parent Form.
''' </summary>
Dim form As New Form2()
form.MdiParent = Me
form.Text = "Form" & count
form.Show()
 
' To Select MDIChildForm when added.
For Each TabItem As ToolStripTabItem In Me.ribbonControlAdv1.Header.MainItems
  If (TryCast(TabItem, ToolStripTabItem)).Panel IsNot Nothing AndAlso TypeOf (TryCast(TabItem, ToolStripTabItem)).Panel Is RibbonPanelMergeContainer Then
    Me.ribbonControlAdv1.SelectedTab = TabItem
    Exit For
  End If
Next TabItem

 

ScreenshotBefore merging childform to parentform

Figure 1: Before merging ChildForm to Parent Form.

After merging childform to parentform    Figure 2: After merging ChildForm to Parent Form.

Samples:

C#:  MergeRibbonPanel

VB:  MergeRibbonPanel

Reference link: https://help.syncfusion.com/windowsforms/ribbon/ribbon-merge-support

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied