MoveToNextRow and RowCount?

Posted by: ginacresse on 8 September 2017, 2:11 pm EST

  • Posted 8 September 2017, 2:11 pm EST

    Hello:


    I'm using this code to cause the cursor to move down the column when the user presses enter, then to the next column when the user gets to the end of the column:


    Dim im As FarPoint.Win.Spread.InputMap


    im = .GetInputMap(FarPoint.Win.Spread.InputMapMode.WhenAncestorOfFocused)


    im.Put(New FarPoint.Win.Spread.Keystroke(Keys.Enter, Keys.None), FarPoint.Win.Spread.SpreadActions.MoveToNextRow)


    im = .GetInputMap(FarPoint.Win.Spread.InputMapMode.WhenFocused)


    im.Put(New FarPoint.Win.Spread.Keystroke(Keys.Enter, Keys.None), FarPoint.Win.Spread.SpreadActions.MoveToNextColumnFirstRow)


     


    But for some reason when I clear the spread with the following the RowCount is incremented by 1 and I get an extra row on the spread that I do not want:


    With .ActiveSheet


    .ClearRange(0, colRowA1, .RowCount, 1, True)


    .ClearRange(0, colRowA2, .RowCount, 1, True)


    End With

    What am I doing wrong?
  • Replied 8 September 2017, 2:11 pm EST

    I found my problem.  My bad.
  • Replied 8 September 2017, 2:11 pm EST

    But I'm still having an issue with the cursor movement.  With the code I originally posted, if the user doesn't enter a value in a cell and just presses enter, the cursor moves to the top of the next column instead of continuing down.  If I change the code to this:


    Dim im As FarPoint.Win.Spread.InputMap


    im = .GetInputMap(FarPoint.Win.Spread.InputMapMode.WhenAncestorOfFocused)


    im.Put(New FarPoint.Win.Spread.Keystroke(Keys.Enter, Keys.None), FarPoint.Win.Spread.SpreadActions.MoveToNextRow)


    im = .GetInputMap(FarPoint.Win.Spread.InputMapMode.WhenFocused)


    im.Put(New FarPoint.Win.Spread.Keystroke(Keys.Enter, Keys.None), FarPoint.Win.Spread.SpreadActions.MoveToNextRow)


     Then when it works except that when I get to the bottom of the column, I want it to automatically move to the top of the next column.


     


    Thanks.

  • Replied 8 September 2017, 2:11 pm EST

    ginacresse,


    In your code, replace MoveToNextRow with MoveToNextRowWrap.  The two actions are similar with the exception that MoveToNextRow stops at the bottom of a column whereas MoveToNextRowWrap wraps from the bottom of one column to the top of the next column.

Need extra support?

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

Learn More

Forum Channels