Hi,
I just quickly went through all threads that returned from my 'DataGridView bound' search and I did find the answer. So, I apologize if this sounds repeated.
I have an 'Invoice' Windows form. On the form I have placed a bound 'DataGridView' to represent the invoice details. Self servicing.
The bindings are as follows:
Control: EntityCollection
Name: ecPOS
Control: BindingSource
Name: bindSource
DataSource: ecPOS
Control: BindingSource
Name: bsPOSDetail
DataSource: bindSource
DataMember: POSDetail
All of this was done declaratively.
When I try to add a new POSDetail entity programmatically to the underlying main form data source, the DataGridView does NOT show the new entity. However, when I try to add the entity to the grid's data source, the grid will show the new entity but the main form data source will not.
Private ReadOnly Property CurrentEntity() As POSEntity
Get
'Return CType(Me.bindingNavigator.BindingSource.Current, POSEntity)
Return m_Current
End Get
End Property
Private Sub tbSearch_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles tbSearch.KeyDown
If e.KeyCode = Keys.Enter Then
If String.IsNullOrEmpty(Me.tbSearch.Text) Then
Return
End If
Dim p As New InventoryItemEntity(Me.tbSearch.Text)
If p.IsNew = False Then
Dim pd As New PosdetailEntity
With pd
.IntSort = 1
.IntLineNo = 1
.StrProductId = p.StrProductId
.DecSalesPrice = p.DecPriceLevel1
.StrUnitAbbreviation = pd.InventoryItem.UnitOfMeasurement.StrUnitAbbreviation
.DecQty = 1
End With
Me.CurrentEntity.Posdetail.Add(pd)
End If
UpdateTotals()
Me.tbSearch.Text = String.Empty
End If
End Sub
Am I doing anything wrong? If so, where? Otherwise, how can I trigger the grid to refresh the data. The 'Refresh' method does NOT work.
Thanks in advance.