Binding a datagridview to a binding source
I am using a datagridview and have bound it to a bindingsource.
In the datagridview i have a combo box column which gives the user a choice of either, ordered, pending, delivered.
However, In this specific grid I just want to display the pending orders. But if I click on the status and select delivered, I want the grid to display "delivered", Until I click save. However, what is happening then I click on the combo box and select delivered it will automatically refresh and not display delivered, only the pending orders. The customer would like to see all the orders that have had their status changed before saving and then displaying all the pending orders again.
The binding source is filtered to display only the orders pending when I select an order from the combo box.
My idea is to select an order from the combox box and display all the pending orders for that order number. The user can then select the status to delivered, if they want to. Then click save to save the changes. The save works fine. But the delivered row will disappear when the combo box loses focus.
Private Sub cboOrdersPending_SelectionChangeCommitted(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboOrdersPending.SelectionChangeCommitted
Try
Me.bsOrderDetails.Filter = String.Format("OrderID = '{0}' AND Status = '{1}'", Me.cboOrdersPending.SelectedValue, "Pending")
Me.dgvPendingOrders.DataSource = Me.bsPendingOrders
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
The code for filling the binding source is as follows:
'Fill all pending orders - these are orders that have been ordered but have not bee delivered
Private Sub FillPendingOrders()
Try
Me.TA_OrderDetails_dsCodeRed1.Fill(Me.DsAddComponetAndEquipment.OrderDetails)
Me.bsPendingOrders.Filter = String.Format("Status = '{0}'", "Pending")
Me.dgvPendingOrders.AutoGenerateColumns = False
Me.dgvPendingOrders.DataSource = Me.bsPendingOrders
'Me.HidePendingOrdersColumn()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Can someone please tell me if i have done something wrong with my code and explanation.
Many thanks for any help,
Steve

