
主要依靠一个控件RibbonBarMergeContainer来实现,虽然可以通过调用RibbonControl控件的创建功能(CreateRibbonTab)来动态的创建,但显然没有命名用RibbonBarMergeContainer来得高效和方便


Dim f As ChildForm1 = New ChildForm1()
f.Show()
f.ribbonBarMergeContainer1.MergeRibbonBars(Me.ribbonControl1)
Me.ribbonControl1.Refresh()
几个主要属性的说明




状态栏的混合
主要使用控件Bar来实现,控件Bar并不能像RibbonControl一样,配合RibbonBarMergeContainer一样进行自动混合,但可以通过控件提供的Items.AddRange来实现控件的添加,Items.RemoveRange来实现控件的移除
混合:
'把混合窗体中的状态栏内的控件收集到列表中
Dim pBaseItem As New System.Collections.Generic.List(Of BaseItem)
Dim pEnumer As IEnumerator = f.BarChild.Items.GetEnumerator()
While pEnumer.MoveNext()
pBaseItem.Add(TryCast(pEnumer.Current, BaseItem))
End While
'加到被混合窗体的状态栏中
Me.Bar1.Items.AddRange(pBaseItem.ToArray())
'把混合好的工具栏列表存储起来,方便下次清除
_barContainerCache.Add(f.Name, pBaseItem)
'刷新
Bar1.Refresh()
清除:
If (_barContainerCache.ContainsKey(pContainer)) Then
Me.Bar1.Items.RemoveRange(_barContainerCache(pContainer).ToArray())
_barContainerCache.Remove(pContainer)
Bar1.Refresh()
End If
