我必须形成一个包含网格视图然后弹出一个弹出窗口,用户可以编辑gridview的值,它保存数据ok但是只有当我关闭主gridview窗口时
但是数据没有在打击网格中被引用,直到我关闭主要表单我从网格双击调用表单
Dim invId As Object = dgDeliverys.Rows(e.RowIndex).Cells("r3DeliveryId").Value
Dim frmedit As New frmedit(invId)
frmedit.ShowDialog()
BindGrid()
然后在新的构造函数中,我使用以下
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
我的ok按钮代码如下
records.Item(0).qty = txtQty.Text
Try
threeContext.dbContext.SaveChanges()
MessageBox.Show("Changes saved to the database.")
Close()
当我关闭编辑行框时,即使我调用了以下构成的绑定方法,它也不会更新数据
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