Results 1 to 3 of 3

Thread: [RESOLVED] Perform Add New method when form loads

  1. #1

    Thread Starter
    Member
    Join Date
    Dec 2011
    Posts
    32

    Resolved [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

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Member
    Join Date
    Dec 2011
    Posts
    32

    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 View Post
    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.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width