Back to Devexpress

How to: Get the Link That Is Hovered Over

windowsforms-4892-controls-and-libraries-navigation-controls-navigation-bar-examples-miscellaneous-how-to-get-the-link-that-is-hovered-over.md

latest1.2 KB
Original Source

How to: Get the Link That Is Hovered Over

  • Nov 13, 2018

The following sample code represents a handler for the MouseMove event. It calculates hit information for the mouse pointer’s position via the NavBarControl.CalcHitInfo method. Then, the link that is hovered over is accessed.

csharp
using DevExpress.XtraNavBar;

private void navBarControl1_MouseMove(object sender, MouseEventArgs e) {
   NavBarHitInfo hitInfo = navBarControl1.CalcHitInfo(new Point(e.X, e.Y));
   if (hitInfo.InLink) {
      NavBarItemLink link = hitInfo.Link;
      // perform operations on the link here
      //...
   }
}
vb
Imports DevExpress.XtraNavBar

Private Sub NavBarControl1_MouseMove(ByVal sender As Object, _
  ByVal e As MouseEventArgs) Handles NavBarControl1.MouseMove
   ' calculating hit information by the current mouse pointer position
   Dim HitInfo As NavBarHitInfo = NavBarControl1.CalcHitInfo(New Point(e.X, e.Y))

   If HitInfo.InLink Then
      Dim Link As NavBarItemLink = HitInfo.Link
      ' perform operations on the link here
      ' ...
   End If
End Sub