WinForms

Upgrade Guide User Guide Demos Support Forums Download
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class GridClickCellsMouseController - WindowsForms API Reference | Syncfusion

    Show / Hide Table of Contents

    Class GridClickCellsMouseController

    This MouseController handles mouse events for cell elements. In its HitTest method, the cell renderer for the cell under the mouse cursor is determined and based on the cell renderer's HitTest result, mouse events will be forwarded to that cell.

    Inheritance
    System.Object
    NonFinalizeDisposable
    GridSubComponent
    GridMouseController
    GridClickCellsMouseController
    Implements
    System.IDisposable
    IMouseController
    IGridFocusHelper
    Inherited Members
    GridMouseController.GetAllowFixFocus()
    GridSubComponent.Grid
    NonFinalizeDisposable.Dispose()
    NonFinalizeDisposable.Dispose(Boolean)
    System.Object.ToString()
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.ReferenceEquals(System.Object, System.Object)
    System.Object.GetHashCode()
    System.Object.GetType()
    System.Object.MemberwiseClone()
    Namespace: Syncfusion.Windows.Forms.Grid
    Assembly: Syncfusion.Grid.Windows.dll
    Syntax
    public class GridClickCellsMouseController : GridMouseController, IDisposable, IMouseController, IGridFocusHelper
    Remarks

    This mouse controller manages the calls to each Cell Renderer's OnHitTest, OnMouseDown, OnMouseHover, OnMouseUp, OnMouseHoverEnter, OnMouseHoverLeave, and OnCancelMode methods. If a cell renderer's OnHitTest method returns a non-zero value, the cell renderer will receive mouse events associated with that cell.

    If a cell has cell button elements and the mouse is over a cell button element, the cell button element will receive all mouse events associated with that cell button element.

    If the user clicks on a cell button element, the cell button element will raise a Click event in its OnMouseUp event handler.

    This MouseController is not used by the GridControl by default. Instead, all this functionality is provided by the GridSelectCellsMouseController. However, the grouping grid control uses this controller to forward events to cell renderers.

    Examples

    This example shows code samples from GroupDropAreaDragHeaderMouseController where the mouse events are forwarded to the GridClickCellsMouseController.

        public class GroupDropAreaDragHeaderMouseController : GroupDragHeaderMouseControllerBase
        {
            public GroupDropAreaDragHeaderMouseController(GridGroupDropArea grid)
            {
                this.groupDropArea = grid;
                isGroupAreaOrigin = true;
                clickCellsController = new GridClickCellsMouseController(grid);
            }
    

    internal GridClickCellsMouseController clickCellsController; int clickCellsControllerHitTest = 0;

    public GridClickCellsMouseController ClickCellsController { get { return clickCellsController; } }

    public void ResetClickCellsController() { if (this.entered) clickCellsController.MouseHoverLeave(EventArgs.Empty); else if (clickCellsControllerHitTest != 0) clickCellsController.CancelMode(); entered = false; clickCellsControllerHitTest = 0; }

    // unrelated code left out here ...

    #region IMouseController implementation

    public virtual string Name { get { return "DragGroupHeader"; } }

    public virtual Cursor Cursor { get { if (cursor != null) return cursor; return clickCellsController.Cursor; } }

    bool entered = false;

    public virtual void MouseHoverEnter() { if (clickCellsControllerHitTest != 0) { entered = true; clickCellsController.MouseHoverEnter(); } }

    public virtual void MouseHover(MouseEventArgs e) { if (clickCellsControllerHitTest != 0) clickCellsController.MouseHover(e); }

    public virtual void MouseHoverLeave(EventArgs e) { if (entered) { clickCellsController.MouseHoverLeave(e); entered = false; } }

    public virtual void MouseDown(MouseEventArgs e) { if (clickCellsControllerHitTest != 0) clickCellsController.MouseDown(e); }

    public virtual void MouseMove(MouseEventArgs e) { if (clickCellsControllerHitTest != 0) clickCellsController.MouseMove(e); }

    public virtual void MouseUp(MouseEventArgs e) { if (clickCellsControllerHitTest != 0) clickCellsController.MouseUp(e); }

    public virtual void CancelMode() { if (clickCellsControllerHitTest != 0) clickCellsController.CancelMode(); }

    public virtual int HitTest(MouseEventArgs e, IMouseController controller) { clickCellsControllerHitTest = clickCellsController.HitTest(e, controller); return clickCellsControllerHitTest; }

    #endregion }

    Constructors

    GridClickCellsMouseController(GridControlBase)

    Initializes a new instance forGridClickCellsMouseController class.

    Declaration
    public GridClickCellsMouseController(GridControlBase grid)
    Parameters
    Type Name Description
    GridControlBase grid

    The parent grid.

    Properties

    Cursor

    The cursor to be displayed.

    Declaration
    public override Cursor Cursor { get; }
    Property Value
    Type Description
    System.Windows.Forms.Cursor
    Overrides
    GridMouseController.Cursor

    Name

    The name of this mouse controller.

    Declaration
    public override string Name { get; }
    Property Value
    Type Description
    System.String
    Overrides
    GridMouseController.Name

    Methods

    CancelMode()

    Occurs when the current mouse operation is cancelled.

    Declaration
    public override void CancelMode()
    Overrides
    GridMouseController.CancelMode()

    HitTest(MouseEventArgs, IMouseController)

    HitTest is called to determine whether your controller wants to handle the mouse events based current context.

    Declaration
    public override int HitTest(MouseEventArgs e, IMouseController controller)
    Parameters
    Type Name Description
    System.Windows.Forms.MouseEventArgs e

    A MouseEventArgs holding event data.

    IMouseController controller

    A mouse controller.

    Returns
    Type Description
    System.Int32

    A non-zero value if the controller can and wants to handle the mouse event; 0 otherwise.

    Overrides
    GridMouseController.HitTest(MouseEventArgs, IMouseController)
    Remarks

    The current winner of the vote is specified through the controller parameter. Your implementation of HitTest can decide if it wants to override the existing vote or leave it.

    MouseDown(MouseEventArgs)

    MouseDown is called when this controller signaled in HitTest that it wants to handle mouse events and the user pressed the mouse button.

    Declaration
    public override void MouseDown(MouseEventArgs e)
    Parameters
    Type Name Description
    System.Windows.Forms.MouseEventArgs e

    The System.EventArgsthat contains event data.

    Overrides
    GridMouseController.MouseDown(MouseEventArgs)
    Remarks

    MouseDown is called and this controller will become the active controller and receive all subsequent mouse message until the mouse button is released or the mouse operation is cancelled.

    MouseHover(MouseEventArgs)

    MouseHover is called when this controller signaled in HitTest that it wants to handle mouse events. MouseHover is called after MouseHoverEnter.

    Declaration
    public override void MouseHover(MouseEventArgs e)
    Parameters
    Type Name Description
    System.Windows.Forms.MouseEventArgs e

    The System.Windows.Forms.MouseEventArgsthat contains event data.

    Overrides
    GridMouseController.MouseHover(MouseEventArgs)

    MouseHoverEnter()

    MouseHoverEnter is called when this controller signaled in HitTest that it wants to handle mouse events. MouseHoverEnter is called before the first time MouseHover is called.

    Declaration
    public override void MouseHoverEnter()
    Overrides
    GridMouseController.MouseHoverEnter()

    MouseHoverLeave(EventArgs)

    MouseHoverLeave is called when hovering ends either because user dragged mouse out of the hit-test area or when context changes (e.g. user pressed the mouse button).

    Declaration
    public override void MouseHoverLeave(EventArgs e)
    Parameters
    Type Name Description
    System.EventArgs e

    The System.EventArgsthat contains event data.

    Overrides
    GridMouseController.MouseHoverLeave(EventArgs)

    MouseMove(MouseEventArgs)

    MouseMove is called for the active controller after a MouseDown message when the user moves the mouse pointer.

    Declaration
    public override void MouseMove(MouseEventArgs e)
    Parameters
    Type Name Description
    System.Windows.Forms.MouseEventArgs e

    The System.EventArgsthat contains event data.

    Overrides
    GridMouseController.MouseMove(MouseEventArgs)

    MouseUp(MouseEventArgs)

    MouseUp is called for the active controller after a MouseDown message when the user releases the mouse button.

    Declaration
    public override void MouseUp(MouseEventArgs e)
    Parameters
    Type Name Description
    System.Windows.Forms.MouseEventArgs e

    The System.EventArgsthat contains event data.

    Overrides
    GridMouseController.MouseUp(MouseEventArgs)

    Implements

    System.IDisposable
    IMouseController
    IGridFocusHelper
    Back to top Generated by DocFX
    Copyright © 2001 - 2022 Syncfusion Inc. All Rights Reserved