Results 1 to 4 of 4

Thread: Zero value problem in datagridview

Threaded View

  1. #1

    Thread Starter
    PowerPoster sparrow1's Avatar
    Join Date
    May 2005
    Location
    Globetrotter
    Posts
    2,820

    Zero value problem in datagridview

    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
    Last edited by dday9; Mar 9th, 2021 at 10:19 AM. Reason: formatted code
    Wkr,
    sparrow1

    If I helped you, don't forget to Rate my post. Thank you

    I'm using Visual Studio.Net 2003 and
    2005
    How to learn VB.Net Create setup with VB 2005 Drawing for beginners VB.Net Tutorials GDI+ Tutorials
    Video's for beginners

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width