I've gat a datagridview bound to a datatable and I want to show Max and Min values.
The code I have is working and showing the proper decimal Max and Min value in a textbox.
The problem I have is when there is a "0" value in the column then de value is always "0".
That is not what I want.
How can I avoid this problem?
The code I have is working and showing the proper decimal Max and Min value in a textbox.
The problem I have is when there is a "0" value in the column then de value is always "0".
That is not what I want.
How can I avoid this problem?
Code:
Dim cells = From r As DataGridViewRow In DataGridView1.Rows.Cast(Of DataGridViewRow)()
Where Not r.IsNewRow
Select CDec(r.Cells(3).Value)
Dim min As Decimal = cells.Min
Dim minval As New cell With {.columnIndex = 3, .rowIndex = Array.IndexOf(cells.ToArray, min)}
Dim max As Decimal = cells.Max
Dim maxval As New cell With {.columnIndex = 3, .rowIndex = Array.IndexOf(cells.ToArray, max)}
TextBox1.Text = max & " / " & min