问题
I have to forms one containing a grid view then a popup that the user can edit the values of the gridview its saving the data ok but only when i close the main gridview window
But the data does not get refershed in the blow grid until i close the main form I am calling the form from the double click of the grid
Dim invId As Object = dgDeliverys.Rows(e.RowIndex).Cells("r3DeliveryId").Value
Dim frmedit As New frmedit(invId)
frmedit.ShowDialog()
BindGrid()
Then in the new constructor i am usig the following
Public Sub New(ByVal recordId As String)
'Call to MyBase.New must be the very first in a constructor.
MyBase.New()
_recordid = recordId
' This call is required by the Windows Form Designer.
InitializeComponent()
records = threeContext.GetAllDeliverysByRecordId(recordId)
txtQty.Text = records.Item(0).qty
End Sub
my ok button code is as follows
records.Item(0).qty = txtQty.Text
Try
threeContext.dbContext.SaveChanges()
MessageBox.Show("Changes saved to the database.")
Close()
when i close the edit line box it does not update the data even though im calling the bind method which consits of the following
Private Sub BindGrid()
Dim bs As New BindingSource
Dim cfglocation As Int16
cfglocation = cfb.StoreLocation
bs.DataSource = (From u In threeContext.R3Delivery Where u.isprocessed = True AndAlso u.location = 1
Select u)
bs.ResetBindings(True)
dgDeliverys.DataSource = bs
End Sub
来源:https://stackoverflow.com/questions/23011805/grid-only-updating-when-main-gridwindow-is-closed