Home Forums WinForms controls Xceed Grid for WinForms An attempt was made to select a row that does not belong… Reply To: An attempt was made to select a row that does not belong…

User (Old forums)
Member
Post count: 23064

We also have the same exception, from times to times (using the latest package – 3.2.9257.09160).  The problem only occur when manual modification are made.  Here a part of our code :

with myGrid

             With .Columns(“unite”)
                .VisibleIndex = oprIncrAft(vIndex)
                .Title = “Qté.”
                .Width = 45
            End With
            AddHandler .DataRowTemplate.Cells(“unite”).ValueChanged, AddressOf showTotal

            With .Columns(“prix_unitaire”)
                .VisibleIndex = oprIncrAft(vIndex)
                .Title = “$ unité”
                .Width = 60
                .FormatSpecifier = “c”
            End With
            AddHandler .DataRowTemplate.Cells(“prix_unitaire”).ValueChanged, AddressOf showTotal

            .Columns.Add(New Xceed.Grid.Column(“sous-total”, GetType(Single)))
            With .Columns(“sous-total”)
                .VisibleIndex = oprIncrAft(vIndex)
                .CellViewerManager = New Xceed.Grid.Viewers.NumericViewer
                .Title = “Sous-Total”
                .ReadOnly = True
                .Width = 75
                .FormatSpecifier = “c”
            End With

end with

    Private Sub showTotal(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Try
            Dim cell As Xceed.Grid.DataCell = CType(sender, Xceed.Grid.DataCell)
            Dim DR As Xceed.Grid.DataRow = cell.ParentRow

            Dim qte As Double = coalesce(DR.Cells(“unite”).Value, 0)
            Dim prix As Double = coalesce(DR.Cells(“prix_unitaire”).Value, 0)
            DR.Cells(“sous-total”).Value = CSng(Math.Round(qte * prix, 2))

            If (cell.IsBeingEdited) Then showGrandTotal()
        Catch ex As Exception
            ErrorManagement(Name, “showTotal”, ex.Message)
        End Try
    End Sub

    Private Sub showGrandTotal()
        Dim sousTotal As Double = 0
        Dim tps As Double = 0
        Dim tvq As Double = 0
        Dim total As Double = 0

        Try
            For t = 0 To Depenses_detailBindingSource.Count – 1
                Dim qte As Double = coalesce(Depenses_detailBindingSource(t)!unite, 0)
                Dim prix As Double = coalesce(Depenses_detailBindingSource(t)!prix_unitaire, 0)

                Dim sousTotalTemp As Double
                Dim tpsTemp As Double = 0
                Dim tvqTemp As Double = 0

                sousTotalTemp = Math.Round(qte * prix, 2)
                sousTotalTemp = Math.Round(sousTotalTemp * CDbl(txtTauxChange.Text), 2)

                sousTotal += sousTotalTemp
                tps += tpsTemp
                tvq += tvqTemp
                total += sousTotalTemp + tpsTemp + tvqTemp
            Next

            txtSousTotal.Text = FormatCurrency(sousTotal)
            txtTPS.Text = FormatCurrency(tps)
            txtTVQ.Text = FormatCurrency(tvq)
            txtTotal.Text = FormatCurrency(total)
        Catch ex As Exception
            ErrorManagement(Name, “showGrandTotal”, ex.Message)
        End Try
    End Sub

Imported from legacy forums. Posted by Daniel (had 2449 views)