Question

I have a datagridview in a windows forms vb.net application. My goal is to have any number over 0.999999999999 12 significant digits to be rounded down to 0.99999999999 11 significant digits. I want to prevent vb.net from rounding these values up to 1. This is how I'm implementing this but I can't figure out which DataGridView Event handler to use.

If DataGridView1.Rows(e.RowIndex).Cells(e.ColumnIndex).Value <= 0.999999999999 Then
                DataGridView1.Rows(e.RowIndex).Cells(e.ColumnIndex).Value = 0.99999999999
            End If
Was it helpful?

Solution

You can change it prior to loading it,

dataGridView1.Columns("ColumnName").DefaultCellStyle.Format = "F11"

or You can write custom logic in the dataGridView_CellFormatting event

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top