AnimatGuiCtrls.Controls.ImageListDrag.StartDrag C# (CSharp) Method

StartDrag() public method

Starts a dragging operation which will use an ImageList to create a drag image and defaults the position of the image to the cursor's drag point.
public StartDrag ( int imageIndex ) : void
imageIndex int The index of the image in /// the ImageList to use for the drag image.
return void
        public void StartDrag(
            int imageIndex
            )
        {
            StartDrag(imageIndex, 0, 0);
        }

Same methods

ImageListDrag::StartDrag ( int imageIndex, int xOffset, int yOffset ) : void

Usage Example

        private void OnMouseMove(object sender, MouseEventArgs args)
        {
            try
            {
                if (args.Button == MouseButtons.Left)
                {
                    //if they are moving the mouse while the left mouse button is down then
                    //they are attempting to drag the item.
                    m_bDraggingIcon = true;

                    m_imageDrag.StartDrag(0, (int)(m_imgDrag.Width / 2), (int)(m_imgDrag.Height / 2));

                    this.DoDragDrop(this, DragDropEffects.Copy);

                    m_imageDrag.CompleteDrag();
                }
            }
            catch (System.Exception ex)
            { string strMsg = ex.Message; }
        }