Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
860
Bug in 2009.2 UltraWinListView drag/drop
posted

Hi there,

I've just upgraded a WinForms 3.5 application to Netadvantage 2009.2. In the application there is a UltraWinListView with drag and drop functionality, pretty much similar to the example shown in this post: http://forums.infragistics.com/forums/t/3539.aspx

The UltraWinListView also uses the ItemDoubleClick event and this is no longer triggered after updating to 2009.2. You can try it out yourself by pasting the code from the above example into a blank solution and subscribe to the ItemDoubleClick event.

PS: I've installed the 2009.2 sample projects and this uses a different implentation (via a custom DragDropManager class) to support drag and drop int the UltraWinListView. This example works ok with subscribing to the ItemDoubleClick event, but I'm not comfortable with pasting this 1047 lines of code DragDropManager class into the project, so I'll replace the UltraWinListView control. Nevertheless the bug (?) should be fixed.

Regards

Rasmus W.

Parents
  • 69832
    Verified Answer
    Offline posted

    The bug is in the snippet I posted; the line that checks the the point to see if it is within the dragRect was causing the drag logic to execute when the point was within the drag rect, and the intention was to execute it when the point is outside that rectangle (see below). Terribly sorry for the inconvenience.

    private void listView_MouseMove(object sender, MouseEventArgs e)
    {
        UltraListView listView = sender as UltraListView;


        //  If the mouse has moved outside the area in which it was pressed,
        //  start a drag operation
        if ( this.lastMouseDown.HasValue )
        {
            Size dragSize = SystemInformation.DragSize;
            Rectangle dragRect = new Rectangle( this.lastMouseDown.Value, dragSize );
            dragRect.X -= dragSize.Width / 2;
            dragRect.Y -= dragSize.Height / 2;

            //  BUG: We want to do this when the dragRect does NOT contain the point.
            //if (dragRect.Contains(e.Location) )
            if (dragRect.Contains(e.Location) == false )
            {
                UltraListViewItem itemAtPoint = listView.ItemFromPoint( e.Location );

                if ( itemAtPoint != null )
                {
                    this.lastMouseDown = null;
                    this.dragItem = itemAtPoint;
                    listView.DoDragDrop( this.dragItem, DragDropEffects.Move );
                }
            }
        }
    }

Reply Children
No Data