DataGridView CheckBox, revert the Value after user confirmation
<p>I have a program and it looks like this</p>
<p><a href="https://i.stack.imgur.com/C6FRt.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/C6FRt.png" alt="enter image description here" /></a></p>
<p>please be focused on the value the one with checked and color red.</p>
<p>Lets say I will click a cell (checkboxcolumn)</p>
<p>if I click a cell a Msgbox will show first sayon <code>Are you you want to update changes?</code></p>
<p>If I click <code>Yes</code> the program will check its current value and Update it something like this.</p>
<pre class="lang-vb prettyprint-override"><code>If value = yes then
   value = No
ElseIf value = no then
   value = Yes
end if
</code></pre>
<p>and if I select <code>NO</code> in the msgbox the value of the current cell will remains the same.</p>
<p>here is my code</p>
<pre class="lang-vb prettyprint-override"><code>If (e.ColumnIndex = 1 AndAlso e.RowIndex &gt;= 0) Then
    Dim value = DirectCast(DataGridView1(e.ColumnIndex, e.RowIndex).FormattedValue, Nullable(Of Boolean))
    Dim result = MessageBox.Show(&quot;Are you sure to uncheck item?&quot;, &quot;&quot;, MessageBoxButtons.YesNoCancel)
    If (value.HasValue AndAlso value = True) Then
        If (result = System.Windows.Forms.DialogResult.Yes) Then
            If DataGridView1(e.ColumnIndex, e.RowIndex).Value = True Then
                DataGridView1(e.ColumnIndex, e.RowIndex).Value = False
            Else
                DataGridView1(e.ColumnIndex, e.RowIndex).Value = True
            End If
        ElseIf (result = System.Windows.Forms.DialogResult.No) Then
        End If
    Else
    End If
End If
</code></pre>
<p>My Question is.</p>
<p>How can I check the the value of cell and turn it vice-versa when I click Yes in the messagebox? and Remains the value or return to its original value when I click NO in the messagebox.</p>
<p>I try my code above but it looks not working</p>
<p>TYSM</p>