logo
VitNX3 Documentation

# VitNX_ScrollBar.OnMouseDown Method

Namespace: VitNX.UI.ControlsV1.Controls
Assembly: VitNX3 (in VitNX3.dll)
Raises the MouseDown event.
VB
C#
F#
C++
JScript
Copy

    protected override void OnMouseDown(
       MouseEventArgs e
    )

    This language is not supported or no code example is available.

#### Parameters

e
  MouseEventArgs

A MouseEventArgs that contains the event data.

Source code
VB
C#
F#
C++
JScript
Copy

    protected override void OnMouseDown(MouseEventArgs e)
     {
         base.OnMouseDown(e);
         if (_thumbArea.Contains(e.Location) && e.Button == MouseButtons.Left)
         {
             _isScrolling = true;
             _initialContact = e.Location;
             _initialValue = _scrollOrientation == VitNX_ScrollOrientation.Vertical ? _thumbArea.Top : _thumbArea.Left;
             Invalidate();
             return;
         }

         if (_upArrowArea.Contains(e.Location) && e.Button == MouseButtons.Left)
         {
             _upArrowClicked = true;
             _scrollTimer.Enabled = true;
             Invalidate();
             return;
         }

         if (_downArrowArea.Contains(e.Location) && e.Button == MouseButtons.Left)
         {
             _downArrowClicked = true;
             _scrollTimer.Enabled = true;
             Invalidate();
             return;
         }

         if (_trackArea.Contains(e.Location) && e.Button == MouseButtons.Left)
         {
             if (_scrollOrientation == VitNX_ScrollOrientation.Vertical)
             {
                 var modRect = new Rectangle(_thumbArea.Left, _trackArea.Top, _thumbArea.Width, _trackArea.Height);
                 if (!modRect.Contains(e.Location))
                     return;
             }
             else if (_scrollOrientation == VitNX_ScrollOrientation.Horizontal)
             {
                 var modRect = new Rectangle(_trackArea.Left, _thumbArea.Top, _trackArea.Width, _thumbArea.Height);
                 if (!modRect.Contains(e.Location))
                     return;
             }
             if (_scrollOrientation == VitNX_ScrollOrientation.Vertical)
             {
                 var loc = e.Location.Y;
                 loc -= _upArrowArea.Bottom - 1;
                 loc -= _thumbArea.Height / 2;
                 ScrollToPhysical(loc);
             }
             else
             {
                 var loc = e.Location.X;
                 loc -= _upArrowArea.Right - 1;
                 loc -= _thumbArea.Width / 2;
                 ScrollToPhysical(loc);
             }
             _isScrolling = true;
             _initialContact = e.Location;
             _thumbHot = true;
             _initialValue = _scrollOrientation == VitNX_ScrollOrientation.Vertical ? _thumbArea.Top : _thumbArea.Left;
             Invalidate();
             return;
         }
     }

    This language is not supported or no code example is available.

Applies to

#### .NET Framework

Supported in: 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8

#### .NET Core

Supported in: 5.0+, 6.0+
See Also
VitNX_ScrollBar Class
VitNX.UI.ControlsV1.Controls Namespace