Log In
Home
Support
Demos
Documentation
Blogs
Training
Webinars
[Expand]General Information
[Collapse]WinForms Controls
  Prerequisites
 [Expand]What's Installed
 [Expand]Build an Application
 [Collapse]Controls and Libraries
  [Expand]Forms and User Controls
  [Expand]Messages, Notifications and Dialogs
  [Expand]Editors and Simple Controls
  [Expand]Ribbon, Bars and Menu
  [Expand]Application UI Manager
  [Expand]Docking Library
  [Expand]Data Grid
  [Expand]Vertical Grid
  [Expand]Pivot Grid
  [Expand]Tree List
  [Expand]Chart Control
  [Expand]Diagrams
  [Expand]Gauges
  [Expand]Map Control
  [Expand]Scheduler
  [Expand]Spreadsheet
  [Expand]Rich Text Editor
  [Expand]Spell Checker
  [Expand]Form Layout Managers
  [Collapse]Navigation Controls
   [Collapse]Navigation Bar
     Views
    [Expand]Appearance
     Save and Restore Layout
    [Collapse]Examples
     [Expand]Appearance
     [Expand]Layout
     [Expand]Miscellaneous
      Responding to User Clicks at Runtime
    [Expand]Member Tables
   [Expand]Accordion Control
    Navigation Frame and Tab Pane
    Navigation Pane
    Tile Bar
   [Expand]TileNav Pane
    WindowsUI Button Panel
   [Expand]Office Navigation Bar
   [Expand]Tile Control
  [Expand]Printing-Exporting
  [Expand]PDF Viewer
   Reporting
  [Expand]Snap
  [Expand]TreeMap Control
 [Expand]Common Features
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Document Server
[Expand]Reporting
[Expand]Report Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

Responding to User Clicks at Runtime

This article is dedicated to various events that can be handled to respond to end-user clicks at runtime.

In this example, the Navigation Bar will be used in a sample application (see the animation below) that utilizes the Navigation Frame - a single document interface (SDI) container that stores multiple pages, but can display only one page at a time. Clicking different child Navigation Bar items should switch active Navigation Frame pages. To do so, you will need to modify the NavigationFrame.SelectedPage property. Refer to the Navigation Frame article to learn about frame pages and ways to populate them.

A Navigation Bar provides two types of child items: items and groups. Items (and their links) are in turn divided into two more categories: regular push items and selectable items (switch between elevated and pressed states as end-users click them). Depending on what type of child items should be clicked to switch the active Navigation Frame page, you will need to handle different events.

Expanded Handling Individual Items' Events

The most straightforward way to respond to clicking a Navigation Bar item at runtime is to handle the related event, raised by this very item. The only event available on this level is the NavBarItem.LinkClicked event. This event is provided by the item and will occur for any link related with this item. The code sample illustrates how to utilize this specific event.

Expanded Handling Global Control Events

Handling click events for each particular child item is the most straightforward way to respond to end-users' clicks. However, it is cumbersome. Any DevExpress navigation control provides one or multiple global events that occur when any child item is clicked. These global events allow you to keep your navigation logic in one spot. For the Navigation Bar control, you can handle one of the following global events.

  • NavBarControl.ActiveGroupChanged - fires when a Navigation Bar group becomes active. At runtime this happens when a user clicks a group caption. Handle this event if your navigation elements are groups rather than items.
  • NavBarControl.LinkClicked and NavBarControl.LinkPressed - fire when an end-user clicks a regular Navigation Bar item. Both events receive an argument of the NavBarLinkEventArgs type, which allows you to identify which specific nav bar item has been clicked. The difference between these events is that the LinkPressed event raises immediately after a user presses a link, while the LinkClick event occurs after the left mouse button is released.
  • NavBarControl.SelectedLinkChanged - this event occurs when end-users click selectable Navigation Bar link. To enable link selection, utilize the NavBarControl.LinkSelectionMode property. Note that selectable links still raise both individual and global LinkClicked events, just like regular links do.

Expanded External Events

External events are those provided not by the target control itself. In case of a Navigation Bar, there can be two possible scenarios.

  • Office Navigation Bar
    The Office Navigation Bar control can be hooked up to your Navigation Bar as its bottom panel (see the Interaction with Navigation Bar article to learn more). In this case, you can handle the OfficeNavigationBar.ItemClick events directly.

  • Content Containers
    The figure below illustrates a very common scenario, where a Navigation Bar group displays a custom control instead of item links. In this example, the custom control is a Tree List that reflects an application hierarchy.

    For this scenario, you obviously cannot use any click events provided by the Navigation Bar. Instead, handle Tree List click events as the code sample below illustrates. This code uses the TreeList.CalcHitInfo method to identify whether or not the clicked Tree List element is a cell. If so, the active Navigation Frame page can be changed. The Frame is accessed through the public parentFrame property, declared in the main form class.

How would you rate this topic?​​​​​​​