No DragOver event for dragging rows?

Posted by: mikes on 16 February 2023, 6:22 pm EST

  • Posted 16 February 2023, 6:22 pm EST

    With AllowRowMove = true and ActiveSheet.RowHeaderVisible = true the user can drag rows up and down.

    The RowDragMove event occurs once when the user begins to drag a row.

    The RowDragMoveCompleted event occurs after the has completed dragging a row.

    Is there a reason why there is no event for during the drag operation - I would have expected like standard windows controls drag events there to be a third event which occurs as the user drags across rows.

    My use case is I want to be able to indicate to the user that there are some rows they cannot drop the dragged row onto. Inspecting in the RowDragMoveCompleted is too late, the drop has already occurred.

  • Posted 20 February 2023, 10:42 pm EST

    Hi Mike,

    Apologize for delay and thanks for reaching out to us. An event like DragOver is not available in Spread. We have raised an enhancement request to the development team to support this event.

    Will get back to you once we have any update from them.[Internal Tracking Id - SPNET-28723]

    Best regards,

    Nitin

  • Posted 21 February 2023, 5:10 pm EST

    Hi,

    As per the development team, For our row moving, there is no such customization. After the row is moved, user cannot customize anything. It’s the reason we think an event like RowDragMoveOver should not be added. Otherwise, there will be a lot of similar event like column moving, row/column resizing, cell selecting…

    In case you want to know if row is moving and needs to find the current row hovered by mouse, then you can just use MouseMove event like the following code:

    
            public Form1()
            {
                InitializeComponent();
                fpSpread1.AllowRowMove = true;
                fpSpread1.RowDragMove += FpSpread1_RowDragMove;
                fpSpread1.RowDragMoveCompleted += FpSpread1_RowDragMoveCompleted;
                fpSpread1.MouseMove += FpSpread1_MouseMove;
            }
            private bool _rowMoving;
    
            private void FpSpread1_MouseMove(object sender, MouseEventArgs e)
            {
                if (_rowMoving)
                {
                    //code to execute during moving row
                    var ht = fpSpread1.HitTest(e.Location.X,e.Location.Y);
                    var row = -1;
                    if (ht != null)
                    {
                        if(ht.Type == HitTestType.RowHeader)
                            row = ht.HeaderInfo.Row;
                        else if(ht.Type == HitTestType.Viewport)
                            row = ht.ViewportInfo.Row;
                        Debug.WriteLine("CurrentRow: " + row);
                    }
                    
                }
            }
    
            private void FpSpread1_RowDragMoveCompleted(object sender, DragMoveCompletedEventArgs e)
            {
                _rowMoving = false;
            }
    
            private void FpSpread1_RowDragMove(object sender, DragMoveEventArgs e)
            {
                _rowMoving = true;
            }
        }

    Please refer the attached sample for the same: SpreadRowDragging.zip

    Best Regards,

    Nitin

  • Posted 21 February 2023, 6:23 pm EST

    Thanks for your reply.

    I don’t see the justification for declining the request to add a row drag over event, the explanation provided does not make any sense to me.

    “As per the development team, For our row moving, there is no such customization. After the row is moved, user cannot customize anything. It’s the reason we think an event like RowDragMoveOver should not be added. Otherwise, there will be a lot of similar event like column moving, row/column resizing, cell selecting…”

    I’m going to try to parse this explanation and break down how it reads to me.

    “As per the development team”

    Ok, this part is easy - you’re telling me the development team have communicated with you.

    “For our row moving, there is no such customization”

    Yes, we know this - that’s what I was asking about.

    “After the row is moved, user cannot customize anything”

    Yes - again, we know this - that’s what I was asking about.

    I don’t know if this is a statement of what is current fact, or what is decreed law by the developers and they are stating that “thou shalt not customise anything once a row has moved”.

    What “row is moved” really means here is unclear - if we take the past tense literal interpretation of moved, you refer to once the user has released the mouse button and the RowDragMoveCompleted has already been raised - but I don’t want to customise anything at that point.

    “It’s the reason we think an event like RowDragMoveOver should not be added”

    I’m sorry, what? What reason? Point to the reason. I missed the reason. No reasons have been presented. Perhaps you refer to the previous sentence “After the row is moved, user cannot customize anything” - which is not a reason, but a statement - but if you were referring to that, then that would be a circular reference.

    “Otherwise, there will be a lot of similar event like column moving, row/column resizing, cell selecting…”

    I get that for the sake of consistency if you add a RowDragOver event people are going to expect you to also have a corresponding ColumnDragOver event… but is that really such a big deal?

    You could always not add a ColumnDragOver event if it’s such an effort and just provide the RowDragOver event and worry about anyone complaining about that inconsistency when that happens.

    But, I’m now doing your job for you and negotiating compromises that could be made to minimise the apparent insurmountable suffering that this improvement would impose on the developers.

    You can decline the request, I’ve coded around this limitation already - I just don’t accept the reasons provided.

  • Posted 22 February 2023, 6:01 pm EST

    Hi,

    Apologize for the inconvenience.

    To prevent affect on other process when a RowDrag started, event like DragOver is not added. So, that the user can’t customize while dragging. However, we are asking to the development team about this.

    Regards,

    Nitin

  • Posted 19 April 2023, 5:39 pm EST

    Hi,

    As per the devlopment team, Spread already have DragOver, which is inherited from Control class. But that event is fired when an object is dragged over the Spread. It is not for dragging Spread’s element. You can see more details about the event here: https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.control.dragover?view=windowsdesktop-7.0

    So, it’s better if you can explain why does you need the event? What’s the data that you want to access from event argument? Then, we can add this event after researching all consequences.

    Regards,

    Nitin

  • Posted 20 April 2023, 10:57 am EST

    The use case I already stated in my initial post.

    Specifically, I have a grid with rows of data and one column is a date column. I want to restrict the user from moving a row by dragging outside a date range - for example, only let the user move a row if where it is being dragged to is the same date.

  • Posted 23 April 2023, 11:02 pm EST

    Hi,

    Apologize for the delay.

    We have forwarded your request to the development team. They have added this enhancement in the to-do list. They will work on it.

    Best Regards,

    Nitin

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels