How to override toolStripButton in bindingNavigator?

Hey Experts,
i have a binding source and binding Navigator that have a toolStripButton (standard) that addes a new item to a datagridview.
My problem is if i click on this toolStripButton 2 times, then i get i NoNullAllowedException Unhandled.
How can i handel that?
PS.: My datagridview has only one column. in this column is PK and NOT NULL
toolStripButton.jpg
delmandiyarAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jaime OlivaresSoftware ArchitectCommented:
in your toolStripButton event (method), check for nullity before any operation. if null just return silently.
0
delmandiyarAuthor Commented:
Hey jaime_olivares

Thank you for quick replay.
Check for nullity befor any operation!! There are not any events that checkes for nullity. How can i do that?
0
delmandiyarAuthor Commented:
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Bob LearnedCommented:
If you have a data source, and a DataGridView, you can bind the data source directly to the DataGridView, and be able to add, edit, and delete rows.
0
delmandiyarAuthor Commented:
But i need this binding navigator.
0
Bob LearnedCommented:
First, I am curious why you "need"?  Second, it looks like you already have a solution from the link that you posted, so what help do you need?
0
delmandiyarAuthor Commented:
first: because the application is for people that need this binding navigator
Second: the solution from the link is just a walk around the problem.
And the walk around is not working for me too.
0
Bob LearnedCommented:
I don't see any problem with the DefaultValuesNeeded event handler approach:

private void dataGridView1_DefaultValuesNeeded(object sender, DataGridViewRowEventArgs e)
{
    e.Row.Cells["Country"].Value = "USA";
    e.Row.Cells["CustomerID"].Value = NewCustomerId();
}
0
delmandiyarAuthor Commented:
There are not any default values!!
So how could i use DefaultValuesNeeded event?? and my table that my datagridview is bounded with, contains only one column.
0
Bob LearnedCommented:
Defining default values when you add rows should keep the DataGridView from complaining about null value.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
delmandiyarAuthor Commented:
I did not solve the problem, but i got a walk around tip.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.