|
-
May 19th, 2006, 02:27 AM
#1
Thread Starter
Lively Member
Delete button
One quick question. I have a delete button and i want when the user press it to get a message "Are you sure you want to delete it?" and when he press yes, it will delete the record. when he press "no", do nothing.
Best Regards
avgoustinosc
-
May 19th, 2006, 02:33 AM
#2
Re: Delete button
What are you using for your database? This will give you the basis for handling the eval of deletion.
VB Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If MessageBox.Show("Are you sure you want to delete?", "Delete Record", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) = DialogResult.Yes Then
'Delete record
End If
End Sub
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
May 19th, 2006, 02:39 AM
#3
Thread Starter
Lively Member
Re: Delete button
Note that im usning the delete button on the tool bar
Private Sub BindingNavigatorDeleteItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BindingNavigatorDeleteItem.Click
End Sub
Best Regards
avgoustinosc
-
May 19th, 2006, 02:40 AM
#4
Thread Starter
Lively Member
Re: Delete button
mainly i need to know how i can say to the system to do nothing when the yes is pressed
Best Regards
avgoustinosc
-
May 19th, 2006, 02:43 AM
#5
Re: Delete button
Oh, ok but I assume then that your using 2005?
Then just presesnt the messagebox like I posted and when they select no, you usse the e.Handled = True to cancel out. I think there is the same argument as I am only running 2003 right now.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
May 19th, 2006, 02:53 AM
#6
Thread Starter
Lively Member
Re: Delete button
Yes, im using 2005. Nevertheless there is no e.handled = true. Is there another way to say "Do Nothing?"
Best Regards
avgoustinosc
-
May 19th, 2006, 03:05 AM
#7
Re: Delete button
There has to =be something similar in the EventArgs?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
May 19th, 2006, 03:18 AM
#8
Thread Starter
Lively Member
Re: Delete button
Nothing.......i tried everything. im sure that something should be there but im new in .net and not too familiar...any other ideas?
Best Regards
avgoustinosc
-
May 19th, 2006, 03:20 AM
#9
Re: Delete button
Not sure. Its hard without having it. 
Have you tried a search in the help files or msdn online?
Just one reason why I like to code my db access instead of using bound controls.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
May 19th, 2006, 05:14 AM
#10
Member
Re: Delete button
Maybe change the argument to your event to...
system.componentModel.cancelEventArgs
and use
e.cancel = true
return
it's what I use to get out of the onClosing event in a similar situation
-
May 19th, 2006, 05:58 AM
#11
Re: Delete button
You can't just change the type of the arguments for an event handler. Different events receive different argument types and its not up to you what they are.
I'm guessing that there is no facility to cancel the delete operation through the BindingNavigator. You may be able to handle the RowDeleted event of the underlying DataTable and then ask for confirmation there. If the user says No you could call RejectChanges on the row that was deleted and it will be magically undeleted.
-
May 22nd, 2006, 10:09 AM
#12
New Member
Re: Delete button
You may create a custom item in the BindingNavigatorToolbar, and execute the BindingSource.RemoveCurrent when desired.
(Sorry my English )
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
|