M
monemas
Guest
hi
I have 2 datagridview One fill of excel The second is to add the search when found closest value
What I want when select specific row from datagridview One
searches for the closest first value before the specified date and searches for the closest first value after the specified date
Send the search result to the second datagridview
Dim str As New List(Of Double)
Dim colosest As Double = 0
For i As Integer = 0 To DataGrid_Excel.RowCount - 1
If Convert.ToDateTime(DataGrid_Excel.SelectedRows.Item(0).Cells(0).Value) > Convert.ToDateTime(DataGrid_Excel.Rows(i).Cells(0).Value) Then
str.Add(DataGrid_Excel.Rows(i).Cells(1).Value)
Dim myDouble As Double = DataGrid_Excel.SelectedRows.Item(0).Cells(1).Value
colosest = str.OrderBy(Function(item) Math.Abs(myDouble - item)).First
If DataGrid_Excel.Rows(i).Cells(1).Value = colosest Then
DataGrid_Search.Rows.Add(New String() {DataGrid_Excel.Rows(i).Cells(0).Value.ToString, DataGrid_Excel.Rows(i).Cells(1).Value})
End If
End If
Next
TabControl1.SelectedIndex = 1
Continue reading...
I have 2 datagridview One fill of excel The second is to add the search when found closest value
What I want when select specific row from datagridview One
searches for the closest first value before the specified date and searches for the closest first value after the specified date
Send the search result to the second datagridview
The result of searching for the closest value before the specified date is one row, regardless of the values being repeated before or after the specified date
Dim str As New List(Of Double)
Dim colosest As Double = 0
For i As Integer = 0 To DataGrid_Excel.RowCount - 1
If Convert.ToDateTime(DataGrid_Excel.SelectedRows.Item(0).Cells(0).Value) > Convert.ToDateTime(DataGrid_Excel.Rows(i).Cells(0).Value) Then
str.Add(DataGrid_Excel.Rows(i).Cells(1).Value)
Dim myDouble As Double = DataGrid_Excel.SelectedRows.Item(0).Cells(1).Value
colosest = str.OrderBy(Function(item) Math.Abs(myDouble - item)).First
If DataGrid_Excel.Rows(i).Cells(1).Value = colosest Then
DataGrid_Search.Rows.Add(New String() {DataGrid_Excel.Rows(i).Cells(0).Value.ToString, DataGrid_Excel.Rows(i).Cells(1).Value})
End If
End If
Next
TabControl1.SelectedIndex = 1
Continue reading...