|
-
Jan 27th, 2006, 11:19 AM
#1
Thread Starter
Frenzied Member
-
May 28th, 2006, 10:35 PM
#2
Re: [RESOLVED] BindingNavigatorDeleteItem VB2005 question
Would you mind posting your solution to this as others have asked the same question. It's always a good idea to post your solution rather than just say you figured it out for that very reason. I've come up with the following solution but I'd be interested to know if you found something better, as I can't see anything native to the BindingNavigator itself.
VB Code:
Private deleteButton As ToolStripItem
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.deleteButton = Me.BindingNavigator1.DeleteItem
End Sub
Private Sub BindingNavigator1_ItemClicked(ByVal sender As Object, ByVal e As System.Windows.Forms.ToolStripItemClickedEventArgs) Handles BindingNavigator1.ItemClicked
If e.ClickedItem Is Me.deleteButton Then
'The user clicked the delete button.
If MessageBox.Show("Are you sure you want to delete the current record?", _
"Confirm Delete", _
MessageBoxButtons.OKCancel, _
MessageBoxIcon.Question, _
MessageBoxDefaultButton.Button2) = Windows.Forms.DialogResult.OK Then
'Allow the record to be deleted.
Me.BindingNavigator1.DeleteItem = Me.deleteButton
Else
'Don't allow the record to be deleted.
Me.BindingNavigator1.DeleteItem = Nothing
End If
End If
End Sub
-
May 28th, 2006, 10:41 PM
#3
Re: [RESOLVED] BindingNavigatorDeleteItem VB2005 question
Alright, found a better solution in this thread, which may well be what you did also.
-
Nov 30th, 2007, 05:31 AM
#4
New Member
Re: [RESOLVED] BindingNavigatorDeleteItem VB2005 question
Well after searching a bit I found an answer to this...
What I did
1) copy the default delete button
2) pasted a new one on the toolstrip 3)
3) renamed it MyDeleteButton
4) I deleted the default button
5)Added this code:
Code:
Private Sub MyDeleteButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyDeleteButton.Click
Me.MyBindingSource.RemoveCurrent()
End Sub
Now I have a delete button I can actually add code to. 
People...for the future, if you are stumped on something and post a question then find an answer PLEASE POST IT instead of saying NM found it. Chances are if you are having a problem with something some one else has or will have the same problem.
-
Nov 30th, 2007, 06:17 PM
#5
Re: [RESOLVED] BindingNavigatorDeleteItem VB2005 question
Actually, there's no need for copying or deleting any buttons. You simply set the DeleteItem property of the BindingNavigator to Nothing so it doesn't do anything automatically when the button is clicked. Then you add a Click event handler for the existing button.
That last solution had the same effect as this because deleting the existing button would make the DeleteItem property Nothing too. It just was more work than is necessary.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|