Reputation: 497
I have a form with a ribbon bar and I want the controls that are on the RibbonPanel
to resize with the rest of the form. The docked RibbonControl
resizes fine and the RibbonPanel resizes with it but the controls that Docked
/Anchored
on the RibbonPanel do not resize.
How do you get controls on a ribbon panel to Dock or Anchor correctly?
Upvotes: 0
Views: 1073
Reputation: 497
For a work around I placed a normal Panel
control inside of the RibbonPanel
control, and docked all the controls I want to resize in that panel. Using a simple resize method and a couple event handlers to dynamically resize that panel, the controls now Anchor
and Dock
normally while on a RibbonPanel.
Private Sub Form1_Resize(sender As System.Object, e As System.EventArgs) Handles MyBase.Resize
Resize()
End Sub
Private Sub RibbonControl1_SelectedRibbonTabChanged(sender As System.Object, e As System.EventArgs) Handles RibbonControl1.SelectedRibbonTabChanged
Resize()
End Sub
Private Sub Resize()
Select Case RibbonControl1.SelectedRibbonTabItem.Name
Case "RibbonTabItem1"
Panel1.Size = RibbonPanel1.Size
Case "RibbonTabItem2"
Panel2.Size = RibbonPanel2.Size
Case ...
End Select
End Sub
Upvotes: 1