Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 42412

Sending data fron one DataGrid to another causes a OutOfRange Error

$
0
0
Code:

Private Sub UpperBound_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UpperBound.ValueChanged
        If loading = 1 Then
            Exit Sub
        End If

        Dim currentvalue As Decimal
        currentvalue = UpperBound.Value + 0.5
        If currentvalue <= LowerBound.Value Then
            UpperBound.Value = currentvalue
        Else
            ExportChart.ChartAreas(0).AxisX.Maximum = UpperBound.Value
        End If

        ExportDataGrid.RowCount = 3
        For row As Integer = 0 To MainForm.DataGrid.RowCount - 1
            If MainForm.DataGrid.Rows(row).Cells(1).Value > LowerBound.Value Then
                If MainForm.DataGrid.Rows(row).Cells(1).Value < UpperBound.Value Then
                    ExportDataGrid.Rows(row).Cells(0).Value = MainForm.DataGrid.Rows(row).Cells(1).Value
                    ExportDataGrid.Rows(row).Cells(1).Value = MainForm.DataGrid.Rows(row).Cells(2).Value
                    ExportDataGrid.Rows(row).Cells(2).Value = MainForm.DataGrid.Rows(row).Cells(3).Value
                    ExportDataGrid.RowCount = ExportDataGrid.RowCount + 1
                End If
            End If
        Next



    End Sub

    Private Sub LowerBound_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LowerBound.ValueChanged
        If loading = 1 Then
            Exit Sub
        End If

        Dim currentvalue As Decimal
        currentvalue = LowerBound.Value - 0.5
        If currentvalue >= UpperBound.Value Then
            LowerBound.Value = currentvalue
        Else
            ExportChart.ChartAreas(0).AxisX.Minimum = LowerBound.Value
        End If

        ExportDataGrid.RowCount = 1

        For row As Integer = 0 To MainForm.DataGrid.RowCount - 1
            If MainForm.DataGrid.Rows(row).Cells(1).Value > LowerBound.Value Then
                If MainForm.DataGrid.Rows(row).Cells(1).Value < UpperBound.Value Then
                    ExportDataGrid.Rows(row).Cells(0).Value = MainForm.DataGrid.Rows(row).Cells(1).FormattedValue
                    ExportDataGrid.Rows(row).Cells(1).Value = MainForm.DataGrid.Rows(row).Cells(2).FormattedValue
                    ExportDataGrid.Rows(row).Cells(2).Value = MainForm.DataGrid.Rows(row).Cells(3).FormattedValue
                    ExportDataGrid.RowCount = ExportDataGrid.RowCount + 1
                End If
            End If
        Next
    End Sub

The Upper Bound subroutine, but the Lower Bound doesn't. Not sure what all to include here, if you need more let me know. :)

Ryan

Viewing all articles
Browse latest Browse all 42412

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>