-1

I am currently working in VB.NET Visual Studio Professional with an SQL back end. I have a DataGridView that populates a list of parts with two CheckBox columns in column positions 0 and 1. Checkbox column in the 0 position is labeled as "Complete" and the checkbox column in position 1 is marked as "Missing." As an operator cuts parts they mark the row as complete or missing with a checkbox in either column. If a part is missing then when the user click the checkbox in the "missing" column it opens a new form as a dialog result. At this point the new form opens and the checkbox in that row under the missing column is checked. However, the operator can click a button on the dialog result to cancel the entry. My problem occurs here. Upon clicking the cancel button the form closes but the checkbox on the original DGV remains check and for some reason I can not get it to uncheck itself. The DGV is data binded to an sql table however the first two checkbox columns are manually added in the design form. Any advice on how to get this checkbox to uncheck itself? Here is my code this far:

ElseIf dr = Windows.Forms.DialogResult.Cancel Then
    MsgBox(Row_Index)
    MsgBox(DGVList.CurrentCell.ColumnIndex)
    'DGVList(Row_Index, 1).Value = True
    DGVList(DGVList.CurrentCell.ColumnIndex, DGVList.CurrentCell.RowIndex).Value = False
   'DGVList("Missing", Row_Index).Value = False
    MsgBox("Hot part has been canceled by user. This part will not be marked as missing.")
End If

My row_index is declared at the top of the sub and both the message boxes seem to correlate to the correct position. To add to this brain tease, on rows 2 and rows 4 the code works, but no where else.

Reza Aghaei
  • 120,393
  • 18
  • 203
  • 398
Cheddar
  • 530
  • 4
  • 30
  • [Show MessageBox on Datagridview Checkbox before Check or UnCheck](http://stackoverflow.com/questions/39529146/show-messagebox-on-datagridview-checkbox-before-check-or-uncheck) – Reza Aghaei Oct 15 '16 at 13:47
  • ok, let me try real quick – Cheddar Oct 15 '16 at 14:22
  • @RezaAghaei I showed the checkbox before check and uncheck and it does return the correct row and column position. – Cheddar Oct 15 '16 at 14:24

1 Answers1

0

I figured it out. I don't know why I had to do it this way but it works.

 Dim val1 as DataGridViewCheckBoxCell = DGVList(DGVList.CurrentCell.ColumnIndex, DGVList.CurrentCell.RowIndex)
 val1.value = false
Cheddar
  • 530
  • 4
  • 30