[RESOLVED] Perform Add New method when form loads
I want to be able to trigger the addnew method of the binding navigator when a form loads.
I am using binding navigator throughout my app, I know its not the best way to go, but this is how I inherited the app so I am continuing it this way for now.
I am accessing a sql database if its important.
I have a datagridview on a summary form that when I double click on the blank line, I want to launch either the new client form or new referral form depending on which grid they double click on. I can get the form to launch, but not activate the add new record method of the Binding Navigator.
Any help would be greatly appreciated.
Steve
Re: Perform Add New method when form loads
The BindingNavigator has no such method, which would explain why you can't call it. The BindingNavigator has a button on it for adding a new method, which automatically calls the AddNew method of the associated BindingSource. The BindingNavigator is just a UI, i.e. an interface for the user. If you want to do something in code then you use the BindingSource.
If you're doing something application-specific in the Click event handler of that button, which would be out of the ordinary but possible, then you have two choices:
1. Call the PerformClick method of that button.
2. Put the code into its own method and call that method from wherever it's needed, i.e. the Click event handler of the BindingNavigator button and also the Load event handler of the form.
Re: Perform Add New method when form loads
what I was able to do was to call the addnew method of the bindingsource in the shown event of the form.
thank you.
Quote:
Originally Posted by
jmcilhinney
The BindingNavigator has no such method, which would explain why you can't call it. The BindingNavigator has a button on it for adding a new method, which automatically calls the AddNew method of the associated BindingSource. The BindingNavigator is just a UI, i.e. an interface for the user. If you want to do something in code then you use the BindingSource.
If you're doing something application-specific in the Click event handler of that button, which would be out of the ordinary but possible, then you have two choices:
1. Call the PerformClick method of that button.
2. Put the code into its own method and call that method from wherever it's needed, i.e. the Click event handler of the BindingNavigator button and also the Load event handler of the form.