Using '.GetViewportLeftColumn(sheetIndex)' on any sheet other than '0' returns incorrect values

Posted by: mchargue on 8 September 2017, 2:49 pm EST

  • Posted 8 September 2017, 2:49 pm EST

    I am using '.GetViewportLeftColumn()' and 
    '.GetViewportRightColumn()'  to get the columns which are visible inside the viewport associated with the SheetView of an fpSpread.  Also, '.GetViewportTopRow()' and 
    '.GetViewportBottomRow()' for the visible rows.

     I'm not certain when the behavior changed, but this all worked in previous releases.  Now, when I am on the second SheetView of an fpSpread, and the SheetView.Columns.Count is equal to 7,  '.GetViewportLeftColumn()' returns '7', and  '.GetViewportRightColumn()' returns '8'

    For the duration of this routine, the fpSpread.ActiveSheet is set to the SheetView that I am working with, and it is visible on screen.  Any ideas about what may be happening here, or what I can do to fix this?
     
  • Replied 8 September 2017, 2:49 pm EST

    Hi,

    It sounds like there is something wrong with the layout of the viewports.  Do you use SuspendLayout/ResumeLayout?

    Things are not supposed to break between releases.  If your code is working differently, please post a sample and info about which versions you are seeing different behavior using, and we will investigate it here and open a bug if necessary.

    I don't think it should ever be possible to get a value back from GetViewportRightColumn that exceeds ColumnCount in the sheet -- that sounds like a bug.

  • Replied 8 September 2017, 2:49 pm EST

    mchargue,

    The GetViewportLeftColumn method in the FpSpread class has two overloads...

    int GetViewportLeftColumn(int columnViewportIndex);
    int GetViewportLeftColumn(int sheetIndex, int columnViewportIndex);

    Which overloaded method are you calling? What arguments are you passing to the method? The title of your post indicated that you are passing the sheetIndex to the overloaded method with a single argument. But that method takes the columnViewportIndex, not the sheetIndex. Thus, your code would be getting the left column of a specified viewport in the first sheet when you really wanted the left column of the first viewport in a specified sheet.

  • Replied 8 September 2017, 2:49 pm EST

    I fixed this be using the overloaded functions that accept an additional column, row input parameter.  Setting this additional input to '0' allows the function to work properly.

    So,

    Dim leftCol as integer = SS.GetViewportLeftColumn(SS.ActiveSheetIndex)

    becomes

    Dim leftCol as integer = SS.GetViewportLeftColumn(SS.ActiveSheetIndex, 0)

    and everything works as before...

Need extra support?

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

Learn More

Forum Channels