0

Currently I have my program hiding blank or empty datagridview cells. I want to find a way to delete these cells entirely. The reason being, after the blank cells were hidden they would reappear after going through some of my other validations. These validations checked to see if the cells contained any invalid input such as negative numbers,non-numeric input and blank cells. If they contained any of the above they would be populated with default values, thus making my hidden cells reappear. Hopefully if there is a way to delete these cells they won't have a change of getting filled with default data. My code to make these cells hidden is below. If anyone can figure out how to delete these cells I would greatly appreciate it! Smile | :)

Private Sub DataGridView1_DataBindingComplete(sender As Object, e As DataGridViewBindingCompleteEventArgs) Handles DataGridView1.DataBindingComplete
   For Each Row As DataGridViewRow In CType(sender, DataGridView).Rows
       Dim Visible As Boolean = True

       If Row.Cells(0).Value Is DBNull.Value Then
           Visible = False
       End If
       Row.Visible = Visible
   Next

End Sub

4

1 回答 1

1

Instead of setting this inside your for loop:

Visible = False

Set this to delete the DBNullValue:

DGV.Rows.RemoveAt(row)
于 2013-08-14T13:12:59.427 回答