Good morning companions.
I put you in situation. I have, in a form made in vb, a DatagridView that I fill from a query on a database, so far so good.
When I mark the Checks that I want, I have 2 ways to save, by pressing the button where it says Save or by pressing the small button on the top left. The first is a Button and the second is a ToolStripButton within a ToolStripMenu.
If I press the save button, it collects all the clicked checkboxes and makes the insertion in my database. If I press the tiny button, it doesn't pick up the last check I pressed, whatever the line, so it doesn't generate the expected result.
And the big mystery, the code for both buttons is exactly the same!
This is how I collect the values of the grid checkboxes:
For Each row As DataGridViewRow In grdItems.Rows
Dim bool1 As Boolean
Dim bool2 As Boolean
Dim bool3 As Boolean
Dim bool4 As Boolean
Dim bool5 As Boolean
bool1 = Boolean.Parse(row.Cells(4).Value.ToString)
bool2 = Boolean.Parse(row.Cells(5).Value.ToString)
bool3 = Boolean.Parse(row.Cells(6).Value.ToString)
bool4 = Boolean.Parse(row.Cells(7).Value.ToString)
bool5 = Boolean.Parse(row.Cells(8).Value.ToString)
...
Next
As I said, both buttons execute the exact same code and I don't give because they behave differently.
All the best.
When you edit a line it goes into 'Edit mode'.
The problem is that when you press the
Button
external 'Save', the edition ends; however, doing it fromToolStripButton
does not end and continues in edit mode, so it does not take into account the changes made.If you activate the left selection bar of the lines you will see that when you press the it
Button
changes to an arrow (indicating that it has finished editing and is selected), while with theToolStripButton
it remains 'in editing' with a pencil.Line edited and that you can collect with your code:
Line in edition and that you will NOT be able to pick up with your code:
To force it to finish editing add: