Object binding to a BindingSource (and probably a DataGridView) – Add New Item


Private Sub DecisionBindingSource_AddingNew(ByVal sender As System.Object, ByVal e As System.ComponentModel.AddingNewEventArgs) Handles DecisionBindingSource.AddingNew

Dim dNew As New Decision
dNew.DateInput = Today
dNew.IsNew = True
dNew.StatusID = Decision.StatusIDEnum.Current

Dim dList As IList(Of Decision) = CType(DecisionBindingSource.DataSource, IList(Of Decision))
dNew.ID = dList.Max(Function(d) d.ID) + 1
e.NewObject = dNew

Catch ex As Exception
End Try

End Sub

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: