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

VS 2019 Zero value problem in datagridview

$
0
0
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?

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


Viewing all articles
Browse latest Browse all 15549

Trending Articles



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