SqlCe BindingSource.AddingNew object - AddingNewEventArgs.NewObject confusion

Answered SqlCe BindingSource.AddingNew object - AddingNewEventArgs.NewObject confusion

  • Monday, February 04, 2013 9:44 PM
     
      Has Code

    OK, I want to use the BindingSource.AddingNew event to create a new database row and automatically fill in some of the feilds before the user enters in the data. For example, I would like to fill in an automatically generated id...things like that. The feilds that I enter in manually the user will not have access to on the form.

    However, I don't know how to create a new row and assign it to the e.NewObject of the AddingNewEventArgs event handler.

    Any help is greatly appreciated. I want my routing to look something like this, but it's not working and I can't think of an alternative.

    Public Sub VenderBindingSource_AddingNew(ByVal sender as Object, ByVal e as AddingNewEventArgs) Handles VenderBindingSource.AddingNew
             ' get error, can't just create a new row
             Dim theNewRow as New DataRow()
             theNewRow.Row.Item(0) = 39233
             e.NewObject = theNewRow
    End Sub

    Thanks,

    neech


    neech

All Replies