Results 1 to 3 of 3

Thread: BindingSource.EndEdit method

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2013
    Location
    San Francisco, CA
    Posts
    470

    BindingSource.EndEdit method

    I would like to trap and handle implicit calls to the EndEdit method of a BindingSource so that I can take action before the values in data-bound controls on a from are pushed to the underlying datasource (BindingSource). Is there a way to do this?

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    109,268

    Re: BindingSource.EndEdit method

    I don't think so. The method cannot be overridden and the ListChanged event that it causes is raised after the change. What specific controls and data source are you dealing with? There may be another way, although it would likely be less convenient.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2013
    Location
    San Francisco, CA
    Posts
    470

    Re: BindingSource.EndEdit method

    Hi jmc -

    The background for my question is that I'm learning more about how to validate a user's data entries and reworking some code with this information.

    My form has a BindingNavigator that is bound to a BindingSource and the controls on the form are data-bound to the BindingSource via their DataBindings. The data in the underlying datasource is bound to a DataTable and is moved to/from an SQLite database file via a DataAdapter. The TextBox controls on the form require validation so they each have a Validating event hander.

    I understand that when the input focus leaves a control, Visual Basic checks the CausesValidation property of the control that is about to receive the focus. If this property is True, Visual Basic fires the Validate event in the control that's about to lose the focus, thus giving the programmer a chance to validate its contents and, if necessary, cancel the focus shift (the Validate event doesn't fire when you're moving the focus from a control whose CausesValidation property is False, even if the control that receives the focus has its CausesValidation property set to True).

    I further understand that the BindingSource.EndEdit method is implicitly called when a control loses the input focus and also when the index position of the BindingSource changes.

    (...please correct me if these two points of understanding are not right ).

    When there is no data in the underlying datasource (i.e., the user is adding the first record so the BindingSource.Position = 0 and the BindingSource.Count = 1 and the BindingNavigator's navigation buttons (MoveFirst, MoveNext, etc.) are disabled) and the form only has a single TextBox control (there is no other control to click or tab into), then what is the best way to trigger the BindingSource.Endit method?

    One technique that I've been using in the above scenario is to click the BindingNavigator.PositionItem control (ToolStrip.TextBox control). This works but it is not very intuitive for the user.

    I appreciate any clarifications and/or advice you can offer.
    Last edited by Mark@SF; Dec 3rd, 2022 at 08:47 AM.

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