I need a way to set items as Completed by clicking on a CheckBox in my bound DataGridView. Once that is done, the item is no longer seen from the DataGridView due to a DataView's row filter.
I have a DataGridView that is bound to a DataView.
Private Sub LoadLispImprovements()
    Private ViewLispImprovements As New DataView
    ViewLispImprovements.Table = Programs.Tables("dtLispImprovements")
    ViewLispImprovements.RowFilter = "Completed=0"
    Lisp_dgvImprovements.DataSource = ViewLispImprovements
End Sub
This DataView's table was set to the following DataTable:

This DataTable has its Primary Key set to the correct field. The Completed field has a red square just to show you guys that I set it as a boolean value.
Take a look at my DataGridView:

Here is where I would click on the checkbox and the item should get filtered out (because the checkbox ShowAll is not checked)
When I click on the CheckBox , the item stays in the DataGridView. In order for it to get filtered out, I must select another row.  Take a look:

And when I change rows, it finally goes away:

How do I get it to remove itself immediatly after I checked the completed checkbox?
P.S: Yes I have the CurrentCellDirtyStateChanged event handler.
Private Sub Lisp_dgvImprovements_CurrentCellDirtyStateChanged(sender As Object, e As System.EventArgs) Handles Lisp_dgvImprovements.CurrentCellDirtyStateChanged
    If Lisp_dgvImprovements.IsCurrentCellDirty Then
        Lisp_dgvImprovements.CommitEdit(DataGridViewDataErrorContexts.Commit)
    End If
End Sub
                You can achieve this by ending the edit of the DataRow when the value of the cell is changed.
Private Sub Lisp_dgvImprovements_CurrentCellDirtyStateChanged(sender As Object, e As System.EventArgs) Handles Lisp_dgvImprovements.CurrentCellDirtyStateChanged
    If (Me.Lisp_dgvImprovements.IsCurrentCellDirty) Then
        Me.Lisp_dgvImprovements.CommitEdit(DataGridViewDataErrorContexts.Commit)
    End If
End Sub
Private Sub Lisp_dgvImprovements_CellValueChanged(sender As System.Object, e As System.Windows.Forms.DataGridViewCellEventArgs) Handles Lisp_dgvImprovements.CellValueChanged
    '                    |-- The index of boolean DataGridViewColumn
    If ((e.ColumnIndex = 0) AndAlso (e.RowIndex > -1)) Then
        With Me.Lisp_dgvImprovements.Rows(e.RowIndex)
            If (Not .IsNewRow) Then
                With DirectCast(.DataBoundItem, DataRowView).Row
                    '     |-- The index of boolean DataColumn
                    .Item(0) = True
                    .EndEdit()
                End With
            End If
        End With
    End If
End Sub
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With