Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2312
  • Last Modified:

Message Box Yes, No, Cancel using BindingNavigatorAddNewItem

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
dave_sky
Asked:
dave_sky
  • 6
  • 4
1 Solution
 
Priest04Commented:
Say that again?
0
 
dave_skyAuthor Commented:
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
 
dave_skyAuthor Commented:
Maybe a better way of summarizing this question:
How to cancel adding a new datagridview row after pressing the BindingNavigatorAddNewItem button?
0
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

 
Priest04Commented:
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
 
Priest04Commented:
No need to cancel it, this way adding is not started, unless you manually call AddNew method.
0
 
dave_skyAuthor Commented:
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
 
Priest04Commented:
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
 
Priest04Commented:
And btw, you dont need Yes, No and Cancel, only Yes and No, what will be the difference between no and cancel?
0
 
dave_skyAuthor Commented:
Priest04,

Ok, I finally got the message - Works fine.

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

Thank you!
0
 
Priest04Commented:
You are welcome.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

  • 6
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now