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

    <P>Hello,</P>
    <P>This line of code returns an empty rectangle, 0, 0, 0, 0:</P>
    <P><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</P></FONT>
  • Replied 8 September 2017, 12:27 pm EST

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

    <P>Hello Bob,</P>
    <P>We are using 2.5.1008. Does that make a difference? Thanks!</P>
  • 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?<br><br>
  • Replied 8 September 2017, 12:28 pm EST

    <P>Hello,</P>
    <P>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:</P>
    <P><SPAN class=kwd>Dim</SPAN> rect1 <SPAN class=kwd>As</SPAN> Rectangle = e.View.GetCellRectangle(0, 0, e.Row, e.Column)</P>
    <P>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?</P>
    <P>Thanks again for all of your help to this point!</P>
    <P>PS. The spread is on a tab page within a form.</P> 
  • Replied 8 September 2017, 12:28 pm EST

    For the benefit of others, the following code works correctly:  <PRE class=coloredcode><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><PRE class=coloredcode>I still don't understand why in my code GetActiveRowViewportIndex returns 0<BR>but GetActiveColumnViewportIndex returns -1.<BR></PRE>
    <P> </P>
    <P> </P>
  • Replied 8 September 2017, 12:28 pm EST

    <P>Hello,</P>
    <P>This tells me you have frozen columns in the Spread.</P>
  • Replied 8 September 2017, 12:28 pm EST

    <P>Hello,</P>
    <P>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!</P>
  • Replied 8 September 2017, 12:28 pm EST

    j2 -<br><br>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?<br>
Need extra support?

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

Learn More

Forum Channels