proceed with the enter key on the cell

Posted by: luis-cifuentes on 8 September 2017, 2:51 pm EST

  • Posted 8 September 2017, 2:51 pm EST

    Hi good afternoon, I want to do the following.
    proceed with the enter key on the fpspread, then at arriving at a particular column, jump to the next row.

    if you could give me a code will appreciate it.

    I forgot how to generate a new row

    Thank you.

    excuse my English, I speak Spanish

     

    Pd: I'm using windows form

  • Replied 8 September 2017, 2:51 pm EST


      You can map the Enter key, here is a code snippet from the installed help file.  



      Example



      This example code sets the input map
      for operation mode Normal for both the object with focus and its ancestor. This
      example sets the Enter key to always move to the next cell.



      [C#]



      // Create an InputMap object.



      FarPoint.Win.Spread.InputMap
      inputmap1;

      // Assign the InputMap object to the existing map.

      inputmap1 = fpSpread1.GetInputMap(FarPoint.Win.Spread.InputMapMode.WhenAncestorOfFocused);



      // Map the Enter key.



      inputmap1.Put(new
      FarPoint.Win.Spread.Keystroke(Keys.Enter, Keys.None),
      FarPoint.Win.Spread.SpreadActions.MoveToNextRow);



      // Create another InputMap object.



      FarPoint.Win.Spread.InputMap
      inputmap2;



      // Assign this InputMap object to
      the existing map.



      inputmap2 =
      fpSpread1.GetInputMap(FarPoint.Win.Spread.InputMapMode.WhenFocused);



      // Map the Enter key.



      inputmap2.Put(new
      FarPoint.Win.Spread.Keystroke(Keys.Enter, Keys.None),
      FarPoint.Win.Spread.SpreadActions.MoveToNextRow);

       



      [Visual
      Basic]



      ' Create an InputMap object.



      Dim inputmap1 As New
      FarPoint.Win.Spread.InputMap()



      ' Assign the InputMap object to the
      existing map.



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



      ' Map the Enter key.



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



      ' Create another InputMap object.



      Dim inputmap2 As New FarPoint.Win.Spread.InputMap()



      ' Assign this InputMap object to the
      existing map.



      inputmap2 =
      FpSpread1.GetInputMap(FarPoint.Win.Spread.InputMapMode.WhenFocused)



      ' Map the Enter key.



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



       



  • Replied 8 September 2017, 2:51 pm EST


    amigos a ver si me ayudan este es el codigo que tengo  lo estoy haciendo con visual basic.net  2008 utilizo fspread para windows v5.0




    Private Sub fpsread_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles detalle_venta.KeyDown
    If e.KeyCode = Keys.Enter Then
    If (detalle_venta.ActiveSheet.ActiveRowIndex + 1 = detalle_venta.ActiveSheet.RowCount) Then
    detalle_venta.ActiveSheet.AddRows(detalle_venta.ActiveSheet.ActiveRowIndex + 1, 1)
    End If
    End If
    End Sub

     

     

    Private Sub fpspread_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles detalle_venta.KeyPress

            If e.KeyChar = ChrW(Keys.Enter) Then
                e.Handled = True
                SendKeys.Send("{TAB}")

            End If
        End Sub

     

    bueno como el titulo dice quiero saltar de la columna 1 a la columna 3 con tecla enter luego dar enter y agregar nueva fila

  • Replied 8 September 2017, 2:51 pm EST

    This would do it.

            private
    void fpSpread1_KeyDown(object
    sender, KeyEventArgs e)

            {

                if
    (e.KeyCode == Keys.Enter)

                    if(fpSpread1.ActiveSheet.ActiveRowIndex
    + 1 == fpSpread1.ActiveSheet.RowCount)

                       
    fpSpread1.ActiveSheet.AddRows(fpSpread1.ActiveSheet.ActiveRowIndex + 1,
    1);

            }



  • Replied 8 September 2017, 2:51 pm EST

    DeepakSharma

     some example?

     

  • Replied 8 September 2017, 2:51 pm EST

    Hello,

    To generate a new row you may capture the KeyDown event for Enter key. Check for the Active row and if it is found to be  the last row increase the RowCount for Spread.

     

     

    Thanks,

  • Replied 8 September 2017, 2:51 pm EST

    Thanks Paul, but in that event insert the code vb.

     

    estoy usando spread win 5 net2.0

  • Replied 8 September 2017, 2:51 pm EST

    Me estan funcionando  los codigos de paul, pero al presionar enter me salta a la columna siguiente y yo quiero saltar a una columna especifica aqui les dejo una imagen de lo que quiero hacer.

    1.- lo otro necesito sumar la columna "Total" y dejar el resultado en un textbox

     2.- cada ves que presiono enter y salta a la siguiente fila me sume(+)

     

    I codes are working paul, but I press enter jumps to the next column and I want to jump to a specific column here I leave a picture of what I do.

    1 .- I need to add another column "Total" and leave the result in a textbox

      2 .- Each time you press enter and jump to the next row I add (+)

    fpspread

     

     
  • Replied 8 September 2017, 2:51 pm EST

    I think from what I understand of your requirements, this should move the activecell as you want it to move, as far as adding a column and and agregating totals in a textbox, I'm not clear on what exactly you want there.

     

    Public Class
    Form1

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

            FpSpread1.ActiveSheet.RowCount = 3

            FpSpread1.ActiveSheet.ColumnCount = 5

        End Sub

     

        Private Sub FpSpread1_KeyDown(sender As
    System.
    Object, e As
    System.Windows.Forms.
    KeyEventArgs) Handles FpSpread1.KeyDown

            Dim
    newRowColumn
    As Integer
    = 3

            Dim
    firstColumn
    As Integer
    = 0

            Dim
    skipToColumn
    As Integer
    = 2

            Dim
    rowCount
    As Integer
    = FpSpread1.ActiveSheet.RowCount

            If
    e.KeyCode =
    Keys.Enter Then

                'First
    Column Selected, skip to specific column

                If
    FpSpread1.ActiveSheet.ActiveColumnIndex = firstColumn
    Then

                   
    FpSpread1.ActiveSheet.SetActiveCell(FpSpread1.ActiveSheet.ActiveRowIndex,

                                                       
    skipToColumn)

                    'New
    row Column Selected in the last row, add row and select first column in it

                ElseIf
    FpSpread1.ActiveSheet.ActiveColumnIndex = newRowColumn
    And

                   
    FpSpread1.ActiveSheet.ActiveRowIndex + 1 = rowCount
    Then

                   
    FpSpread1.ActiveSheet.AddRows(FpSpread1.ActiveSheet.RowCount, 1)

                   
    FpSpread1.ActiveSheet.SetActiveCell(FpSpread1.ActiveSheet.ActiveRowIndex
    + 1,

                                                       
    firstColumn)

                    'New
    row Column Selected but not the last row, select first column in next row

                ElseIf
    FpSpread1.ActiveSheet.ActiveColumnIndex = newRowColumn
    And

                   
    FpSpread1.ActiveSheet.ActiveRowIndex + 1 <> rowCount
    Then

                   
    FpSpread1.ActiveSheet.SetActiveCell(FpSpread1.ActiveSheet.ActiveRowIndex
    + 1,

                                                       
    firstColumn)

                    'Not
    the first or new row column, select the next column

                ElseIf
    FpSpread1.ActiveSheet.ActiveColumnIndex >= skipToColumn
    Then

                   
    FpSpread1.ActiveSheet.SetActiveCell(FpSpread1.ActiveSheet.ActiveRowIndex,



                                                       
    FpSpread1.ActiveSheet.ActiveColumnIndex + 1)

                End
    If

            End If

            e.Handled = True

        End Sub

    End Class



  • Replied 8 September 2017, 2:51 pm EST

    Paul

    quiero utilizar el evento keypress
    y no no keydown

     

    does not give the results I want

    I want to use the keypress event
    and no keydown

    A million thanks, paul

  • Replied 8 September 2017, 2:51 pm EST

    Luis, According to the MSDN Library the KeyPress event is not fired for non-character keys, only the Keydown or Keyup events are fired for non-character keys, if you want to use the Keypress event you will need to use something other than the Enter key. See the link below.

    http://msdn.microsoft.com/en-us/library/system.windows.forms.control.keypress.aspx

  • Replied 8 September 2017, 2:51 pm EST

    Hello,

    The code that you have used to go to increase the row count is correct. You may set the InputMap for Spread for Enter key as shown by Paul in his earlier post.

     

    Thanks,

     

  • Replied 8 September 2017, 2:51 pm EST

    I can't give you an example using KeyPress
  • Replied 8 September 2017, 2:51 pm EST

    Hello,

    The code provided by you in the above post, for moving to specific columns using the KeyDown event would work correctly in both the cases, that is for Spread with 7 columns as well as for Spread with 10 columns. Please let me know if you still face any issues with this code or if you have any queries further.

    Thanks,

    Manpreet Kaur.

  • Replied 8 September 2017, 2:51 pm EST

    ok paul, can give me example with keydown,but 7 columns and other with 10 colums please.
    how the picture sent your mail thank.

    you send  my code.

    "detalle_venta=fpspread"

    "this have 7 columns "

     this is correct?

    no keypress

    keypress 

    Private Sub detalle_venta_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles detalle_venta.KeyDown


            Dim newRowColumn As Integer = 3
            Dim firstColumn As Integer = 0
            Dim skipToColumn As Integer = 2
            Dim rowCount As Integer = detalle_venta.ActiveSheet.RowCount


            If e.KeyCode = Keys.Enter Then

                'First Column Selected, skip to specific column

                If detalle_venta.ActiveSheet.ActiveColumnIndex = firstColumn Then

                    detalle_venta.ActiveSheet.SetActiveCell(detalle_venta.ActiveSheet.ActiveRowIndex, skipToColumn)

                    'New row Column Selected in the last row, add row and select first column in it

                ElseIf detalle_venta.ActiveSheet.ActiveColumnIndex = newRowColumn And detalle_venta.ActiveSheet.ActiveRowIndex + 1 = rowCount Then

                    detalle_venta.ActiveSheet.AddRows(detalle_venta.ActiveSheet.RowCount, 1)

                    detalle_venta.ActiveSheet.SetActiveCell(detalle_venta.ActiveSheet.ActiveRowIndex + 1, firstColumn)

                    'New row Column Selected but not the last row, select first column in next row

                ElseIf detalle_venta.ActiveSheet.ActiveColumnIndex = newRowColumn And detalle_venta.ActiveSheet.ActiveRowIndex + 1 <> rowCount Then

                    detalle_venta.ActiveSheet.SetActiveCell(detalle_venta.ActiveSheet.ActiveRowIndex + 1, firstColumn)

                    'Not the first or new row column, select the next column

                ElseIf detalle_venta.ActiveSheet.ActiveColumnIndex >= skipToColumn Then
                    detalle_venta.ActiveSheet.SetActiveCell(detalle_venta.ActiveSheet.ActiveRowIndex, detalle_venta.ActiveSheet.ActiveColumnIndex + 1)

                End If

            End If

            e.Handled = True

        End Sub

     

     

    keydown 

     "detalle_factura=fpspread"

    this have 10 columns

    this is correct?

    no keypress OK

       Private Sub detalle_factura_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles detalle_factura.KeyDown

           Dim PrimeraColumnaCodigo As Integer = 0
            Dim ColumnaFecha As Integer = 4
            Dim ColumnaCantidad As Integer = 5
            Dim ColumnaPrecioneto As Integer = 6
            Dim rowCount As Integer = detalle_factura.ActiveSheet.RowCount

            If e.KeyCode = Keys.Enter Then

                'esta en la columna 0 de la fila activa
                If detalle_factura.ActiveSheet.ActiveColumnIndex = PrimeraColumnaCodigo Then
                    'saltamos a la columa de la fecha
                    detalle_factura.ActiveSheet.SetActiveCell(detalle_factura.ActiveSheet.ActiveRowIndex, 4)
                    MsgBox("FEcha")

                    ' si esta en la columna Fecha de la fila activa
                ElseIf detalle_factura.ActiveSheet.ActiveColumnIndex = 4 Then
                    'saltamos a la columna cantidad
                    detalle_factura.ActiveSheet.SetActiveCell(detalle_factura.ActiveSheet.ActiveRowIndex, 5)
                    'MsgBox("En cantidad")

                ElseIf detalle_factura.ActiveSheet.ActiveColumnIndex = 5 Then
                    'saltamos a la columna cantidad
                    detalle_factura.ActiveSheet.SetActiveCell(detalle_factura.ActiveSheet.ActiveRowIndex, 6)
                    'MsgBox("En Precio neto")

                    ' si esta en el precio neto

                ElseIf detalle_factura.ActiveSheet.ActiveColumnIndex = 6 Then

                    MultiplicaColumna()
                    CalculoTotal()

                    detalle_factura.ActiveSheet.AddRows(detalle_factura.ActiveSheet.RowCount, 1)
                    detalle_factura.ActiveSheet.SetActiveCell(detalle_factura.ActiveSheet.ActiveRowIndex + 1, 0)


                Else
                    MsgBox("nOSE QUE PASA ACA")
                    End If

            End If
            e.Handled = True


        End Sub

    sorry my English
     

     

     

     

     

     

  • Replied 8 September 2017, 2:51 pm EST

    Hi,

    Maybe these will help? 

    Managing Keyboard Interaction

    Managing Events from User Actions

    Those help context are from the user's guide.  The full documentation is here (and in the online help).

  • Replied 8 September 2017, 2:51 pm EST

    but you can give me an example with 6 columns, please

    send you some pictures to your email thanks

     

    helpme please

Need extra support?

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

Learn More

Forum Channels