e.View.GetCellRectangle returns empty rectangle

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

  • Posted 8 September 2017, 12:28 pm EST

    Hello,


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


    <FONT color=#0000ff size=2>Dim</FONT><FONT size=2> location </FONT><FONT color=#0000ff size=2>As</FONT><FONT size=2> Point = e.View.GetCellRectangle(0, 0, e.Row, 0).Location

    </FONT>
  • 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

    What event are you doing this in?
  • 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?
  • 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:


    <SPAN class=kwd>Dim</SPAN> rect1 <SPAN class=kwd>As</SPAN> 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:  
    <SPAN class=kwd>Dim</SPAN> dataColumnRectangle <SPAN class=kwd>As</SPAN> Rectangle
    <SPAN class=kwd>With</SPAN> e.View
    dataColumnRectangle = .GetCellRectangle( _
    .GetActiveRowViewportIndex, .GetActiveColumnViewportIndex, e.Row, 0)
    <SPAN class=kwd>End With</SPAN></PRE>
    I still don't understand why in my code GetActiveRowViewportIndex returns 0
    but GetActiveColumnViewportIndex returns -1.

    <P> 


     

  • Replied 8 September 2017, 12:28 pm EST

    Hello,


    This tells me you have frozen columns in the Spread.

Need extra support?

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

Learn More

Forum Channels