ColumnWidthChanged event gives wrong value of column width

Posted by: Jose.Aguirre on 23 August 2023, 5:52 pm EST

  • Posted 23 August 2023, 5:52 pm EST

    Hello,

    when subscribed to the event:

    gcSpreadSheet.ColumnWidthChanged += OnGdmSpreadSheetColumnWidthChanged;

    a wrong value for the dragged column is returned.

    Steps:

    • create 2x2 sheet (columns A and B)
    • drag column A to the left as much as possible (behind the limits)
    • visually the width of column A seems to be 0 but when catching in the event above the value of:
    spreadSheet.ActiveSheet.Columns[e.ColumnList[0]].Width

    it is still the previous value.

  • Posted 24 August 2023, 8:17 pm EST

    Hi,

    I think you meant for Resizing and not for dragging. Please correct if we are wrong.

    We have replicated this issue at our end while resizing a column to Zero width and it still taking the previous one.

    This issue seems like a bug. So, we have escalated it to the development team. Will get back to you once we have any update from them.[Intearnal tracking Id - SPNET-32983]

    Regards,

    Nitin

  • Posted 24 August 2023, 9:59 pm EST

    Yes, you are right. It happens when resizing.

  • Posted 27 August 2023, 5:26 pm EST

    Hi,

    As per the development team, The current behavior of Column.Width is by design. Because the internal implementation of set column width doesn’t change the column width to 0 when the column parameter is 0.

    We recommend using the Column.ActualWidth property to get the correct column width.

    Try below code to achieve your requirement:

    spread.ActiveSheet.Columns[e.ColumnList[0]].ActualWidth

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

    Regards,

    Nitin

Need extra support?

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

Learn More

Forum Channels