C1Flexgrid KeyActionenter

Posted by: saidnai on 15 January 2024, 1:03 am EST

  • Posted 15 January 2024, 1:03 am EST

    Hi,

    As in the pictures attached. I have set KeyActionEnter for a C1Flexgrid to MoveDown, but it is not doing it in the exe.

    This mean when i enter the weight and push the Enter key the cursor does not go to the next Cell down. The Cell is only not in input modus anymore.

    Is this combined with another property?

    Best regards

    Said

  • Posted 15 January 2024, 1:04 am EST - Updated 15 January 2024, 1:09 am EST

    Sorry here is the picture.

  • Posted 15 January 2024, 9:36 pm EST

    Hello Said,

    We are sorry, but we could not replicate the behavior. We tried to set KeyActionEnter to MoveDown, put some value in a cell, and press the Enter key. It worked as expected. Please refer to the attached GIF (see KeyActionEnter.zip).

    Could you please let us know the version of FlexGrid you are using on your end and also check the behavior with the latest version of control to see if it is still reproducible?

    Could you please provide us with a stripped-down sample so that we could observe and investigate the behavior on our end?

    Regards,

    Uttkarsh.

  • Posted 16 January 2024, 1:36 am EST

    Dear Uttkarsh,

    I found the source of the problem as follow:

    Step 1: The Flexgrid will be loaded with code.

    **Code: **

    Private Sub DGV1RDLaden()

    Try

    Cursor.Current = Cursors.WaitCursor

            DGV1RD.DataSource = Nothing
            DGV1RD.Rows.RemoveRange(1, DGV1RD.Rows.Count - 1)
            SqlStr = "SELECT Field1, Field2, Field3, Field4, Field5, Field6, Field7, Field8, Field9, Field10, Field11, Field12, Field13, Field14 FROM MischRezepturP " &
                     "WHERE Field1 = 1 ORDER BY Reihenfolge"
            Dim Odbcda As New Odbc.OdbcDataAdapter(SqlStr, connectionString)
            odbcDataSet = New DataSet
            Odbcda.Fill(odbcDataSet, "V1Liste")
            'Dim dt As DataTable = odbcDataSet.Tables("V1Liste")
            dtDGV1RD = odbcDataSet.Tables("V1Liste")
            DGV1RD.DataSource = dtDGV1RD
            With DGV1RD
                .Cols(1).Width = 0
                .Cols(1).AllowEditing = False
    
                .Cols(2).Width = 0                  '
                .Cols(2).AllowEditing = False
    
                .Cols(3).Width = 0                  '
                .Cols(3).AllowEditing = False
    
                .Cols(4).Width = 0                  '
                .Cols(4).AllowEditing = False
    
                .Cols(5).Width = 0
                .Cols(5).AllowEditing = False
    
                .Cols(6).Caption = "Field6"    '
                .Cols(6).Width = 80
                .Cols(6).Format = "N"
                .Cols(6).TextAlignFixed = C1.Win.C1FlexGrid.TextAlignEnum.RightCenter
    
                .Cols(7).Caption = "Field7"       '
                .Cols(7).Width = 200
                '.Cols(7).AllowEditing = False
    
                .Cols(8).Caption = "Field8"        '
                .Cols(8).Width = 60
                .Cols(8).Format = "0.0"
                .Cols(8).TextAlignFixed = C1.Win.C1FlexGrid.TextAlignEnum.RightCenter
                .Cols(8).AllowEditing = False
    
                .Cols(9).Caption = "Field9"    '
                .Cols(9).Width = 80
                .Cols(9).AllowEditing = False
    
                .Cols(10).Caption = "Field10"    '
                .Cols(10).Width = 100
    
                .Cols(11).Width = 0
                .Cols(11).AllowEditing = False
    
                .Cols(12).Width = 0                 '
                .Cols(12).AllowEditing = False
    
                .Cols(13).Width = 0                 '
                .Cols(13).AllowEditing = False
    
                .Cols(14).Width = 0
                .Cols(14).AllowEditing = False
            End With
    
            DGV1RDTotals()
    
            'DGV1RD.KeyActionEnter = KeyActionEnum.MoveDown
    
    
            Cursor.Current = Cursors.Default
    
        Catch ex As Exception
            MsgBox("Error 'DGV1RDLaden' :" & vbCrLf & ex.ToString, MsgBoxStyle.Critical)
        Finally
            Cursor.Current = Cursors.Default
        End Try
    

    Step 2: when the user change a value in the cell, i call a function to update columns in the same in the row.

    **Code: **

    Dim TempV11

    Private Sub DGV1RD_StartEdit(sender As Object, e As RowColEventArgs) Handles DGV1RD.StartEdit

    TempV11 = DGV1RD(e.Row, e.Col)

    End Sub

    Private Sub DGV1RD_AfterEdit(sender As Object, e As RowColEventArgs) Handles DGV1RD.AfterEdit
        Try
                'Anteil erneut berechnen
                Dim rw As Integer = 0
                For Each r As Row In DGV1RD.Rows
                    If rw = 0 Then
                        rw += 1
                    Else
                        If DGV1RD.Item(rw, 3) Is DBNull.Value Or DGV1RD.Item(rw, 3) Is Nothing Or GetValue(DGV1RD.Item(rw, 3)) = 0 Then
                            Exit For
                        Else
                            'Ohne Datenbank
                            If DGV1RD.Item(rw, 6) Is DBNull.Value Then
                            Else
                                If GetDoublebool(NetDGV1RD) And GetDoublebool(DGV1RD.Item(rw, 6)) Then
                                    'Gewicht Rohstoff / Gewicht gesamte Mischung * 100
                                    DGV1RD.Item(rw, 8) = Double.Parse((Double.Parse(DGV1RD.Item(rw, 6)) / Double.Parse(NetDGV1RD)) * 100).ToString("N")
                                Else
                                    DGV1RD.Item(rw, 8) = 0
                                End If
                            End If
                        End If
                        rw += 1
                    End If
                Next
                DGV1RDTotals()
    
        Catch ex As Exception
            MsgBox("Error 'DGV1RD_AfterEdit' :" & vbCrLf & ex.ToString, MsgBoxStyle.Critical)
        End Try
    End Sub
    

    Step 3: I call a function to refresh the total.

    **Code: **

    Private Sub DGV1RDTotals()

    Try

    Cursor.Current = Cursors.WaitCursor

            If IsNothing(DGV1RD.DataSource) Then
            Else
                DGV1RD.Select(-1, -1)
                DGV1RD.Tree.Column = 1
                DGV1RD.SubtotalPosition = SubtotalPositionEnum.BelowData
                'DGV1RD.SubtotalPosition = SubtotalPositionEnum.AboveData
                'clear existing totals
                DGV1RD.Subtotal(AggregateEnum.Clear)
    
                'calculate subtotals (three levels, totals on every column)
                Dim c As Integer
                For c = 6 To DGV1RD.Cols.Count - 1
                    If c = 6 Or c = 8 Then
                        DGV1RD.Subtotal(AggregateEnum.Sum, 0, -1, c, "Summe")
                    End If
                    If c > 9 Then
                        Exit For
                    End If
                Next
    
                'set up styles
                Dim s As CellStyle = DGV1RD.Styles(CellStyleEnum.Subtotal0)
                s.BackColor = Color.Green
                s.ForeColor = Color.White
                s.Font = New Font("Microsoft Sans Serif", 8, FontStyle.Bold)
                s.Format = "#,###.##"
                s.TextAlign = TextAlignEnum.RightCenter
    
                DGV1RD.AutoSizeRows()
            End If
    
            Cursor.Current = Cursors.Default
    
        Catch ex As Exception
            MsgBox("Error 'DGV1RDTotals' : " & vbCrLf & ex.ToString, MsgBoxStyle.Critical)
        Finally
            Cursor.Current = Cursors.Default
        End Try
    End Sub
    

    After this steps the KeyActionenter does not working.

    Best regards

    Said

  • Posted 16 January 2024, 11:00 pm EST

    Hello Said,

    We are sorry, but we couldn’t replicate the behavior by using a code similar to the one you provided. Please refer to the attached sample (see FlexGrid48_KeyActionEnter_VB.zip)

    The code you provided had some unknowns, like GetValue(), GetDoublebool(), NetDGV1RD, etc. We tried to use your given code as much as possible, but because of some unknowns and the absence of a dummy DataSource, we could not reconstruct it completely on our end.

    Could you please modify the attached sample so that it is replicable on our end too?

    Regards,

    Uttkarsh.

  • Posted 18 January 2024, 9:31 pm EST

    Dear Uttkarsh,

    I have commented the code and aslo add a class for the GetValue(), GetDoublebool().

    The variable NetDGV1RD contains a weight like (2000kg / 20) * 100 to get a percentage of the material.

    Best regards

    Said

  • Posted 18 January 2024, 9:34 pm EST

    Dear Uttkarsh,

    Please add the necessary DLLs.

    Best regards

    Said

    FlexGrid48_KeyActionEnter_VB.zip

  • Posted 21 January 2024, 11:14 pm EST

    Hello Said,

    In your DGV1RDTotals() method, you are selecting Cell [row:-1, col:-1]. Thus, after editing, the previous selection will be replaced when you select a different cell. Please try commenting out the line and verifying if this aligns with your intended behavior.

    'the below line is causing the issue
    DGV1RD.Select(-1, -1)


    Please refer to the attached modified sample. (see FlexGrid48_KeyActionEnter_VB_Mod.zip)

    Regards,

    Uttkarsh.

  • Posted 22 January 2024, 12:23 am EST

    Dear Uttkarsh,

    It was the below line causing the issue:

    “DGV1RD.Select(-1, -1)”

    it works now.

    Thanks a lot

    Said

  • Posted 22 January 2024, 3:26 pm EST

    Hello Said,

    We are glad that the solution worked out for you.

    If you require any further assistance or have any questions, please do not hesitate to reach out to us.

    Regards,

    Uttkarsh

Need extra support?

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

Learn More

Forum Channels