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