Quantcast
Channel: DevExpress Support Center (Examples)
Viewing all articles
Browse latest Browse all 7205

How to show the NavPaneForm programmatically?

$
0
0

When the "NavigationPane" view is applied, the NavBarControl can be collapsed to save space by clicking on a small arrow button within the control's caption. When collapsed, the NavBarControl still allows the contents of the active group to be displayed. To do this, an end-user can simply click the group's caption. Once clicked, the NavPane Form, which contains the active group's content, is displayed.


Starting with version 14.2, the required code is as simple as that:

[C#]
navBarControl1.ShowNavPaneForm(); 

 

So, for example, if you want to open the form when an active group changes (the NavBarControl.ActiveGroupChanged  event), the required code would be:

[C#]
privatevoidnavBarControl1_ActiveGroupChanged(objectsender,DevExpress.XtraNavBar.NavBarGroupEventArgse){if(navBarControl1.OptionsNavPane.NavPaneState==NavPaneState.Collapsed){navBarControl1.ShowNavPaneForm();}} 

 


For previous versions, the solution is a bit more complex because you need to access internal methods of our NavBarControl. You can do this using the reflection: 

[C#]
       privatevoidShowActiveGroupPopup()       {           if(navBarControl1.OptionsNavPane.NavPaneState==NavPaneState.Collapsed)           {               NavBarViewInfoviewInfo=navBarControl1.GetViewInfo();               varmi=viewInfo.GetType().GetMethod("DoContentButtonPress",System.Reflection.BindingFlags.NonPublic|System.Reflection.BindingFlags.Instance);               mi.Invoke(viewInfo,null);           }       }       voidnavBarControl1_ActiveGroupChanged(objectsender,NavBarGroupEventArgse)       {           if(navBarControl1.OptionsNavPane.NavPaneState==NavPaneState.Collapsed)           {               ShowActiveGroupPopup();           }       }

 

 If you want to show the form even when the active group is clicked again, additionally handle the Click event:

[C#]
voidnavBarControl1_Click(objectsender,EventArgse){varargs=(MouseEventArgs)e;varhi=navBarControl1.CalcHitInfo(args.Location);if(hi.InGroupCaption&&hi.Group==navBarControl1.ActiveGroup)ShowActiveGroupPopup();} 

 








Viewing all articles
Browse latest Browse all 7205

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>