Try using the CellFormatting event:
Private Sub dgv_CellFormatting(sender As Object, _
e As DataGridViewCellFormattingEventArgs) _
Handles dgv.CellFormatting
If (e.ColumnIndex = 0) Then
If e.Value IsNot Nothing AndAlso DirectCast(e.Value, Double) = 0 Then
e.Value = String.Empty
e.FormattingApplied = True
End If
End If
End Sub
The Double type isn't great for comparisons. Consider using a Decimal type instead.
Trying to keep the cells "blank" for the new row until they were "touched" by the user requires hacking around with a flag on each cell of the new row, so here is an example using the Tag property:
Dim rowEditing As Integer = -1
Private Sub dgv_RowEnter(sender As Object, _
e As DataGridViewCellEventArgs) _
Handles dgv.RowEnter
If e.RowIndex = dgv.NewRowIndex Then
rowEditing = e.RowIndex
For i As Integer = 0 To dgv.Columns.Count - 1
dgv.Rows(rowEditing).Cells(i).Tag = "tagged"
Next
End If
End Sub
Private Sub dgv_RowLeave(sender As Object, _
e As DataGridViewCellEventArgs) _
Handles dgv.RowLeave
If rowEditing > -1 Then
For i As Integer = 0 To dgv.Columns.Count - 1
dgv.Rows(rowEditing).Cells(i).Tag = String.Empty
Next
rowEditing = -1
End If
End Sub
Private Sub dgv_CellEndEdit(sender As Object, _
e As DataGridViewCellEventArgs) _
Handles dgv.CellEndEdit
If e.RowIndex = rowEditing AndAlso e.ColumnIndex = 1 Then
dgv.Rows(e.RowIndex).Cells(e.ColumnIndex).Tag = String.Empty
End If
End Sub
Private Sub dgv_CellFormatting(sender As Object, _
e As DataGridViewCellFormattingEventArgs) _
Handles dgv.CellFormatting
If e.RowIndex = rowEditing AndAlso e.ColumnIndex = 1 Then
If dgv.Rows(e.RowIndex).Cells(e.ColumnIndex).Tag IsNot Nothing AndAlso _
dgv.Rows(e.RowIndex).Cells(e.ColumnIndex).Tag = "tagged" Then
If e.Value IsNot Nothing Then
e.Value = String.Empty
e.FormattingApplied = True
End If
End If
End If
End Sub
This example is just testing the second column with is of the type Double.