MoveToNextColumn just works at the row level

Posted by: bdota on 8 September 2017, 2:37 pm EST

  • Posted 8 September 2017, 2:37 pm EST

    some code like this:

                inputMap = spreadOne.GetInputMap(InputMapMode.WhenFocused);

                inputMap.Put(new Keystroke(Keys.Enter, Keys.None),SpreadActions.MoveToNextColumn);

     

     

     

     ok, it is good, navigating to the next cell on the same Row BUT when it reached the last cell of the current row, it stops :( I want it to go to the next row and start navigating again from the next row. 

    what should I add to that code?

     

     

     

    Thanks.

     

     

  • Replied 8 September 2017, 2:37 pm EST

    ok, I added some code to do that but still wondering if without adding extra code if there is a way to set to go to next row.

           private void mySpread_KeyDown(object sender, KeyEventArgs e)

            {

                if(e.KeyCode == Keys.Enter)

                {

                    int currentCol = mySpread.ActiveSheet.ActiveCell.Column.Index;

                    if(currentCol < mySpread.ActiveSheet.ColumnCount-1)

                    {

                        InputMap inputMap;

                        inputMap = mySpread.GetInputMap(InputMapMode.WhenFocused);

                        inputMap.Put(new Keystroke(Keys.Enter, Keys.None),SpreadActions.MoveToNextColumn);

                    }

                    else

                    {

                        InputMap inputMap;

                        inputMap = mySpread.GetInputMap(InputMapMode.WhenFocused);

                        inputMap.Put(new Keystroke(Keys.Enter, Keys.None), SpreadActions.MoveToNextRowFirstColumn);


                    }

                }

            }

     

     

     

     

     

     

  • Replied 8 September 2017, 2:37 pm EST

    Hello,

    Unfortunately I don't find a direct way to achieve this with out using some code. Here is another approach that you may follow:

    Dim im As FarPoint.Win.Spread.InputMap

        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

     
            FpSpread1.ActiveSheet.ColumnCount = 4

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

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

        End Sub

     
        Private Sub FpSpread1_EnterCell(ByVal sender As Object, ByVal e As FarPoint.Win.Spread.EnterCellEventArgs) Handles FpSpread1.EnterCell

            If e.Column = FpSpread1.ActiveSheet.ColumnCount - 1 Then

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

            Else

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

            End If

        End Sub

     

    Thanks,

     

  • Replied 8 September 2017, 2:37 pm EST

    The MoveToNextColumn action is designed to move the active cell to the next column in the row until the end of the row is reached and then stop.  This action would typically be associated with the right arrow key.  The MoveToNextColumnWrap action is designed to move the active cell to the next column in the row until the end of the row is reached and then wrap to the first cell in the next row.  This action would typically be associated with the tab key.


    Simply change you input map setup code to use the MoveToNextColumnWrap action and then you can remove your mySpread_KeyDown code.


        inputMap.Put(new Keystroke(Keys.Enter, Keys.None), SpreadActions.MoveToNextColumnWrap);

  • Replied 8 September 2017, 2:37 pm EST

    nice, thank you Sir.
Need extra support?

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

Learn More

Forum Channels