Solved

Message Box Yes, No, Cancel using BindingNavigatorAddNewItem

Posted on 2008-10-18
10
2,187 Views
Last Modified: 2012-06-21
I need a Message Box for Yes, No, Cancel using the BindingNavigatorAddNewItem.

I have tried several samples but none will cancel the addnew.

Thanks for your help!
0
Comment
Question by:dave_sky
  • 6
  • 4
10 Comments
 
LVL 18

Expert Comment

by:Priest04
ID: 22752674
Say that again?
0
 

Author Comment

by:dave_sky
ID: 22752956
When a user adds a new row to a datagridview using the BindingNavigatorAddNewItem button -
I need a Message Box for Yes, No, Cancel.

Or, using this code:
Private Sub BindingNavigatorAddNewItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BindingNavigatorAddNewItem.Click
        If MessageBox.Show("Are you are sure you want to create a new blank Quote?", _
                       "You could make a copy.", _
       MessageBoxButtons.YesNo) = DialogResult.Yes Then
            Me.TblIncomeStatementBindingSource.AddNew()
        End If
    End Sub

How can I modify - "MessageBoxButtons.YesNo) = DialogResult.Yes Then
            Me.TblIncomeStatementBindingSource.AddNew()"

To DialogResult.No instead of DialogResult.Yes?




 
0
 

Author Comment

by:dave_sky
ID: 22753294
Maybe a better way of summarizing this question:
How to cancel adding a new datagridview row after pressing the BindingNavigatorAddNewItem button?
0
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 
LVL 18

Accepted Solution

by:
Priest04 earned 500 total points
ID: 22753336
In the property window of the BindingNavigator, find property AddNewItem and set it to None. This will allow you to add record manually, like in the code you have provided.

Goran
0
 
LVL 18

Expert Comment

by:Priest04
ID: 22753343
No need to cancel it, this way adding is not started, unless you manually call AddNew method.
0
 

Author Comment

by:dave_sky
ID: 22753372
The AllowUserToAddRows property is already set to 'False".

I have no problem adding the new row - I want to be able to cancel the adding of the new row with a messagebox.
0
 
LVL 18

Expert Comment

by:Priest04
ID: 22753395
dave, where did I talked about setting AllowUserToAddRows to false? Read my reply thoroughly.

If you want this:

- user clicks on + button to add new record
- messagebox pops out aksing the user if he want to add a record
- if yes, start adding new record, if no, nothing happened, adding new record is not started

then this is what your code will do, when you set the property I talked about.
0
 
LVL 18

Expert Comment

by:Priest04
ID: 22753403
And btw, you dont need Yes, No and Cancel, only Yes and No, what will be the difference between no and cancel?
0
 

Author Comment

by:dave_sky
ID: 22753429
Priest04,

Ok, I finally got the message - Works fine.

This will solve a lot of other bindingnavigator messagebox problems for me.

Thank you!
0
 
LVL 18

Expert Comment

by:Priest04
ID: 22753435
You are welcome.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question