e.View.GetCellRectangle returns empty rectangle

Posted by: j2associates on 8 September 2017, 12:27 pm EST

  • Posted 8 September 2017, 12:27 pm EST

    Hello,


    This line of code returns an empty rectangle, 0, 0, 0, 0:


    Dim location As Point = e.View.GetCellRectangle(0, 0, e.Row, 0).Location

  • Replied 8 September 2017, 12:27 pm EST

    What event are you doing this in?
  • Replied 8 September 2017, 12:28 pm EST

    Hello Bob,


    We are using 2.5.1008. Does that make a difference? Thanks!

  • Replied 8 September 2017, 12:28 pm EST

    It's working correctly for me in that version as well.  Do you have some other code anywhere that might be affecting it?

  • Replied 8 September 2017, 12:28 pm EST

    Hello,


    I found the problem (I think) but I don't understand what it is telling me. All of the examples I have seen use 0 as the defaults for the ViewPort indices with the GetCellRectangle method so I called it like so because I wanted the left most column value:


    Dim rect1 As Rectangle = e.View.GetCellRectangle(0, 0, e.Row, e.Column)


    When I set the ColumnViewPortIndex to -1, the values showed up properly. But what does that mean and how do I read that value in case it changes again? Does scrolling impact this in any way?


    Thanks again for all of your help to this point!


    PS. The spread is on a tab page within a form.

     
  • Replied 8 September 2017, 12:28 pm EST

    For the benefit of others, the following code works correctly:  
    Dim dataColumnRectangle As Rectangle
    With e.View
    dataColumnRectangle = .GetCellRectangle( _
    .GetActiveRowViewportIndex, .GetActiveColumnViewportIndex, e.Row, 0)
    End With
    I still don't understand why in my code GetActiveRowViewportIndex returns 0
    but GetActiveColumnViewportIndex returns -1.

     


     

  • Replied 8 September 2017, 12:28 pm EST

    Hello,


    This tells me you have frozen columns in the Spread.

  • Replied 8 September 2017, 12:28 pm EST

    Hello,


    Sorry, I was just opening up my post to edit if for that. The code is in the CellClick event. The funny thing is the code was working for a while. The first time I noticed a problem with it was after I scrolled within the spread control itself. Now it always returns an Rectangle.Empty. Thanks!

  • Replied 8 September 2017, 12:28 pm EST

    j2 -

    I am not able to reproduce this.  It returns a value on each occasion.  I tested this using 2.5.2009.  What version are you using?  Could you attach a small project reproducing this for us to debug?
Need extra support?

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

Learn More

Forum Channels