P
Patrick A
All,
My code (below) causes 2 rows disappear from the DataGridView when I
expect it to delete 1.
I'm going around circles...can someone please steer me in the right
direction?
Thanks,
In the following code,
Can anyone tell me what I've done wrong? In addition, if anyone knows
of a good working sample of code where you can delete all of the
"highlighted" rows from a DataGridView (if that's what you want) I'm
all ears! (Or eyes.)
Private Sub BindingNavigatorDeleteItem_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
BindingNavigatorDeleteItem.Click
Dim myAnswer As System.Windows.Forms.DialogResult =
MessageBox.Show("Once you delete a button, it's gone. Delete it?",
"Delete?", MessageBoxButtons.YesNoCancel)
Select Case myAnswer
Case Windows.Forms.DialogResult.Yes
If Me.TBL_TimersDataGridView.SelectedRows.Count > 0
AndAlso _
Not
Me.TBL_TimersDataGridView.SelectedRows(0).Index = _
Me.TBL_TimersDataGridView.Rows.Count - 1 Then
Me.TBL_TimersDataGridView.Rows.RemoveAt( _
Me.TBL_TimersDataGridView.SelectedRows(0).Index)
Me.TBL_TimersBindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.L55TimerDataSet)
End If
Case Windows.Forms.DialogResult.No
Me.Focus()
Case Windows.Forms.DialogResult.Cancel
Me.Focus()
End Select
End Sub
My code (below) causes 2 rows disappear from the DataGridView when I
expect it to delete 1.
I'm going around circles...can someone please steer me in the right
direction?
Thanks,
In the following code,
clicking the Yes button makes 2 rows disappear from the DataGridView, (which I don't want) but only 1 delete from the underlying db (as desired).
clicking the No button makes 1 row disappear from the DataGridView, (which I don't want) with none deleting from the underlying db (as desired).
clicking the Cancel button has the same effect as clicking the No button.
Can anyone tell me what I've done wrong? In addition, if anyone knows
of a good working sample of code where you can delete all of the
"highlighted" rows from a DataGridView (if that's what you want) I'm
all ears! (Or eyes.)
Private Sub BindingNavigatorDeleteItem_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
BindingNavigatorDeleteItem.Click
Dim myAnswer As System.Windows.Forms.DialogResult =
MessageBox.Show("Once you delete a button, it's gone. Delete it?",
"Delete?", MessageBoxButtons.YesNoCancel)
Select Case myAnswer
Case Windows.Forms.DialogResult.Yes
If Me.TBL_TimersDataGridView.SelectedRows.Count > 0
AndAlso _
Not
Me.TBL_TimersDataGridView.SelectedRows(0).Index = _
Me.TBL_TimersDataGridView.Rows.Count - 1 Then
Me.TBL_TimersDataGridView.Rows.RemoveAt( _
Me.TBL_TimersDataGridView.SelectedRows(0).Index)
Me.TBL_TimersBindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.L55TimerDataSet)
End If
Case Windows.Forms.DialogResult.No
Me.Focus()
Case Windows.Forms.DialogResult.Cancel
Me.Focus()
End Select
End Sub