Ticket T309559
Visible to All Users

Spreadsheet control's VisibleRange is null when handling SizeChanged event

created 9 years ago

Hi I'm currently using DevExpress SpreadsheetControl in my WinForms project.

I'm encountering an issue where the Spreadsheet Control's VisibleRange is detected as null when the SizeChanged event is handled even though the spreadsheet control's columns and rows are still visible. eg. resizing or maximizing the window size. Can I please ask if this behaviour is expected? Is it possible to get the VisibleRange when handling the SizeChanged event?

Attached is a sample project where I'm able to reproduce the behaviour and a winword document that describes what I have encountered when running the sample project.

Thank you.

Answers approved by DevExpress Support

created 9 years ago (modified 9 years ago)

UPDATED ON November 11 2015
Thank you for providing me with a more detailed description of your scenario. I see the issue. The matter is that the SpreadsheetControl.VisibleRange property returns a valid value only when a SpreadsheetControl's layout is completely calculated. In your scenario (maximizing/restoring a main window), the SpreadsheetControl's layout is not entirely calculated when the SpreadsheetControl.SizeChanged event is raised, even if the SpreadsheetControl.VisibleRange property is analyzed within the BeginInvoke method call.
We have plans to provide an additional event which is raised when a visible range in the SpreadsheetControl is changed. However, we have not yet decided in what exact version this event will be implemented.
You can add the following thread to your favorites to be automatically notified of any changes regarding this feature:
Add an event that will be raised in reaction to the visible range change

In the meantime, I can only suggest you re-calculate the SpreadsheetControl's layout by executing the SpreadsheetControl.Refresh method when the the SpreadsheetControl.VisibleRange property value is null. Please refer to the following code:
[C#] I hope you will find this information helpful.

    Show previous comments (1)
    DevExpress Support Team 9 years ago

      Hi Kuan Yong,
      Thank you for providing me with a more detailed description of your scenario. I see the issue. The matter is that the SpreadsheetControl.VisibleRange property returns a valid value only when a SpreadsheetControl's layout is completely calculated. In your scenario (maximizing/restoring a main window), the SpreadsheetControl's layout is not entirely calculated when the SpreadsheetControl.SizeChanged event is raised, even if the SpreadsheetControl.VisibleRange property is analyzed within the BeginInvoke method call.
      We have plans to provide an additional event which is raised when a visible range in the SpreadsheetControl is changed. However, we have not yet decided in what exact version this event will be implemented.
      You can add the following thread to your favorites to be automatically notified of any changes regarding this feature:
      Add an event that will be raised in reaction to the visible range change

      In the meantime, I can only suggest you re-calculate the SpreadsheetControl's layout by executing the SpreadsheetControl.Refresh method when the the SpreadsheetControl.VisibleRange property value is null. Please refer to the following code:

      C#
      private void spreadsheetControl1_SizeChanged(object sender, EventArgs e) { spreadsheetControl1.BeginInvoke(new MethodInvoker(delegate() { var visibleRange = spreadsheetControl1.VisibleRange; if(visibleRange == null) { spreadsheetControl1.Refresh(); visibleRange = spreadsheetControl1.VisibleRange; } System.Diagnostics.Debug.Print("visibleRange: {0}", visibleRange == null ? "null" : visibleRange.ToString()); if(visibleRange != null) { System.Diagnostics.Debug.Print("Top row index: {0}", visibleRange.TopRowIndex); System.Diagnostics.Debug.Print("Bottom row index: {0}", visibleRange.BottomRowIndex); System.Diagnostics.Debug.Print("Left column index: {0}", visibleRange.LeftColumnIndex); System.Diagnostics.Debug.Print("Right column index: {0}", visibleRange.RightColumnIndex); } })); }

      I hope you will find this information helpful.

        Hi Oleg,
        Thanks again for your explaination and assistance. I think your suggestion and workaround is useful and will work for now. Please mark the suggestion as solution.
        Thank you.

        DevExpress Support Team 9 years ago

          You are welcome!
          I am happy to hear that my assistance was helpful to you.
          Should you have additional questions regarding our products or need my further assistance, do not hesitate to contact me.

          P.S. I have updated my previous answer with information from my last comment. If you wish, you can mark this answer as a solution.

          Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

          Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.