How to access VerticalScrollBar.Value?

Posted by: gw.noh on 24 March 2022, 12:37 pm EST

  • Posted 24 March 2022, 12:37 pm EST

    I need VerticalScrollBar.Value, but I can’t read it because of the protection level.

    How to use this value like Scroll.Value in WinForm?

  • Posted 24 March 2022, 7:49 pm EST


    The Value of the VerticalScrollBar is used and managed internally, it is not public property. Could you please let us know what you want to achieve using the Value of the VerticalScrollbar so that we can help you accordingly?

    Regards Avnish

  • Posted 24 March 2022, 8:06 pm EST

    When I change the scroll mode to pixels, I want to know the exact scroll value for use in the next code.

    int imgWidth = 100;
    int imgHeight = 100;
    var verticalScrollValue = fpSpread1.VerticalScroll.Value;
    var horizonScrollValue = fpSpread1.HorizonScroll.Value;
    fpSpread1_Sheet1.AsWorksheet().Shapes.AddShape(AutoShapeType.Rectangle, horizonScrollValue , verticalScrollValue, imgWidth , imgHeight );
  • Posted 28 March 2022, 8:11 pm EST


    Could you please provide some details about your use case? As we understand you are trying to add a shape. Do you want the shape to be added to the middle of the currently displayed cells, or do you want the shape to be added to the top-left corner of the currently displayed cells?

    Regards Avnish

  • Posted 31 March 2022, 5:24 pm EST - Updated 30 September 2022, 4:13 am EST

    1. Yes, I’m trying to add a shape.
    2. I want the shape to be Added to the middle of the currently displayed cell.
    3. Currently displayed Cell is scrolled half.

  • Posted 4 April 2022, 8:47 pm EST


    You can use the following code to add shape to a cell in the middle of the shown cells.

    var activeColView = fpSpread1.GetActiveColumnViewportIndex();
                var activeRowView = fpSpread1.GetActiveRowViewportIndex();
                var rightCol = fpSpread1.GetViewportRightColumn(activeColView);
                var leftCol = fpSpread1.GetViewportLeftColumn(activeColView);
                int col = leftCol;
                if (leftCol < rightCol) {
                    col = (leftCol + rightCol) / 2;
                var row = fpSpread1.GetViewportTopRow(activeRowView);
                RectangleShape shape = new RectangleShape();
                shape.BackColor = Color.Red;
                shape.Size = new Size(100, 100);
                fpSpread1.ActiveSheet.AddShape(shape, row, col);
                fpSpread1.ShowCell(activeRowView, activeColView, row, col, FarPoint.Win.Spread.VerticalPosition.Nearest, FarPoint.Win.Spread.HorizontalPosition.Center);

    We have attached a sample showing the same. If you face any issues, just let us know. Regards Avnish

Need extra support?

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

Learn More

Forum Channels