ColumnWidthChanged vs ColumnWidthChanging

4 posts, 0 answers
  1. Curtis
    Curtis avatar
    70 posts
    Member since:
    Oct 2014

    Posted 02 Apr Link to this post

    Hello!

    I need to capture when column-resizing with a mouse has COMPLETED.  I expected this would be done in ColumnWidthChanged but for reasons unknown to me that event fires WHILE the user is resizing...exactly like how I would expect ColumnWidthChanging  to work.

     

    It's like the resize is happening "Live" instead of waiting for the user to complete their resize THEN firing. 

    Any suggestions would be very much appreciated!

     

     

     

     

  2. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3891 posts

    Posted 07 Apr Link to this post

    Hello, Curtis,  

    The ColumnWidthChanged event is expected to be fired when the width of a column is changed. When the resize cursor is shown and you move the mouse, this adjusts the width accordingly while the resize operation is still ongoing. The column's width is indeed affected. That is why the ColumnWidthChanged event is fired. The ColumnWidthChanging event on the other hand is expected to be fired in a similar situation just before the width property is changed since it allows cancelling the change operation.

    In order to detect when the resize operation is completed, it is possible to handle the RadGridView.MouseUp event, check the RadGridView.Cursor and the element under the mouse: 
            private void radGridView1_MouseUp(object sender, MouseEventArgs e)
            {
                if (this.radGridView1.Cursor == Cursors.SizeWE)
                {
                    GridHeaderCellElement headerCell = this.radGridView1.ElementTree.GetElementAtPoint(e.Location) as GridHeaderCellElement;
                    if (headerCell != null)
                    {
                        //TODO
                    }
                }
            }
    I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

    Regards,
    Dess | Tech Support Engineer, Sr.
    Progress Telerik

    Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
    Our thoughts here at Progress are with those affected by the outbreak.
  3. Curtis
    Curtis avatar
    70 posts
    Member since:
    Oct 2014

    Posted 07 Apr in reply to Dess | Tech Support Engineer, Sr. Link to this post

    It helps a great deal, thank you!  I'm afraid it makes no sense whatsoever though and that's a bit troubling.

    The CHANGING event should be firing BEFORE AND DURING the change.   The CHANGED event should fire after the 'change' has occurred.   Asking your users to capture the mouse cursor in order to tell what happened to the grid...???  That's a little harsh IMO.

  4. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3891 posts

    Posted 09 Apr Link to this post

    Hello, Curtis,  

    Thank you for providing your feedback. It is really appreciated.

    I completely understand your point. It sounds more like that you need ColumnWidthChangeStart and ColumnWidthChangeEnd events which are not available in RadGridView out-of-the-box. 

    However, we strive to follow some general approaches with the public API for the controls in the Telerik UI for WinForms suite. Usually, any x_Changing event is purposed to be fired when the certain property is about to be changed. This event should be cancel-able so the developer can determine whether the user can proceed further or not. If the x_Changing is not cancelled, the operation can proceed further and the x_Changed event is fired indicating that the property has already been changed. This logic is followed for the columns in RadGridView as well. 

    We haven't had any complains about this API from other customers so far. However, if other customers find it inconvenient, we will definitely consider it in the future improvement of the control.

    For now, feel free to use the previously suggested approach which I believe would fit your requirements.

    Should you have further questions please let me know.

    Regards,
    Dess | Tech Support Engineer, Sr.
    Progress Telerik

    Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
    Our thoughts here at Progress are with those affected by the outbreak.
Back to Top