示例#1
0
        /// <summary>
        /// Raises the <see cref="ItemDragging" /> event.
        /// </summary>
        /// <param name="e">The <see cref="CancelListBoxItemDragEventArgs" /> instance containing the event data.</param>
        protected virtual void OnItemDragging(CancelListBoxItemDragEventArgs e)
        {
            EventHandler <CancelListBoxItemDragEventArgs> handler;

            handler = this.ItemDragging;

            handler?.Invoke(this, e);
        }
示例#2
0
        /// <summary>
        /// Raises the <see cref="E:System.Windows.Forms.Control.MouseMove"/> event.
        /// </summary>
        /// <param name="e">A <see cref="T:System.Windows.Forms.MouseEventArgs"/> that contains the event data. </param>
        protected override void OnMouseMove(MouseEventArgs e)
        {
            if (!this.IsDragging && e.Button == MouseButtons.Left && this.IsOutsideDragZone(e.Location))
            {
                CancelListBoxItemDragEventArgs args;

                args = new CancelListBoxItemDragEventArgs(this.DragIndex);

                this.OnItemDragging(args);

                if (!args.Cancel)
                {
                    this.IsDragging = true;
                    this.DoDragDrop(this.DragIndex, DragDropEffects.Move);
                }
            }

            base.OnMouseMove(e);
        }