Step 13. Enabling Data Manipulation
So far you have only set up the window to retrieve data. In this step you will add logic to the Customer Orders window that allows you to manipulate the data you have retrieved.
Manipulating Order Detail Data
- In this step you will add an event handler for the order detail New button.
- In Visual Studio, open the Customer Orders window in design mode, and go to the Properties tab. Double-click the order detail New button. This adds a btnOrderDetailNew_Click event handler to the form. Add the following code to the event handler method:
Private Sub btnOrderDetailNew_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles btnOrderDetailNew.Click
Me.OrderDetail.NewEntity(New OrderDetailDefaults(Me.Order.Entity.OrderID))
Me.grdOrderDetail.SelectedIndex = Me.grdOrderDetail.Items.Count - 2
Me.grdOrderDetail.Focus()End Sub
The method calls the Order Detail business object's NewEntity method passing an OrderDetailDefaults object. Note the order id value is pulled from the Order entity object and passed to the default value object for use in populating the order detail record with the appropriate parent order id. Afterwards, this code navigates to the newly added row (the last in the DataGrid) and sets focus to the DataGrid.
© (c) 2026 Oak Leaf Enterprises, Inc., 1996-2026 • Updated: 04/19/18
Comment or report problem with topic
