We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

How to programmatically dock the XPMenus bar ?

 

The XPMenus bar cannot be docked directly since it is not of the type control. So first, get the CommandBar that hosts this bar using the MainFrameBarManager’s GetBarControl method and then dock this CommandBar like any other dockable control. Please refer the below code snippet which illustrates this:

C#

CommandBar cmdbar = this.mainFrameBarManager1.GetBarControl(this.bar1);

cmdbar.DockState = CommandBarDockState.Left;

this.RecalcBarLayout(cmdbar);

Private void RecalcBarLayout(CommandBar cmdbar)

{

// Call method RedockIfNeeded

MethodInfo mInfo = typeof(CommandBar).GetMethod("RedockIfNeeded", BindingFlags.Instance | BindingFlags.InvokeMethod | BindingFlags.NonPublic);

if (mInfo != null)

{

mInfo.Invoke(cmdbar, new object[] { });

}

// Call method OnCommandBarStateChanged

mInfo = typeof(CommandBar).GetMethod("OnCommandBarStateChanged", BindingFlags.Instance | BindingFlags.InvokeMethod | BindingFlags.NonPublic);

if (mInfo != null)

{

mInfo.Invoke(cmdbar, new object[] { EventArgs.Empty });

}

}

VB

Dim cmdbar As CommandBar = MainFrameBarManager1.GetBarControl(Bar1)

cmdbar.DockState = CommandBarDockState.Left

Me.RecalcBarLayout(cmdbar)

Private Sub RecalcBarLayout(ByVal cmdbar As CommandBar)

' Call method RedockIfNeeded

Dim mInfo As MethodInfo = GetType(CommandBar).GetMethod("RedockIfNeeded", BindingFlags.Instance Or BindingFlags.InvokeMethod Or BindingFlags.NonPublic)

If Not mInfo Is Nothing Then

mInfo.Invoke(cmdbar, New Object() {})

End If

' Call method OnCommandBarStateChanged

mInfo = GetType(CommandBar).GetMethod("OnCommandBarStateChanged", BindingFlags.Instance Or BindingFlags.InvokeMethod Or BindingFlags.NonPublic)

If Not mInfo Is Nothing Then

mInfo.Invoke(cmdbar, New Object() {EventArgs.Empty})

End If

End Sub

Sample:

http://websamples.syncfusion.com/samples/KB/Tools.Windows/TPGDock/main.htm

Article ID: Published Date: Last Revised Date: Platform: Control:
1167 04/30/2011 07/10/2014 Windows Forms XPToolbar
Tags:
Did you find this information helpful?
Add Comment
You must log in to leave a comment

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.