Grid only updating when main gridwindow is closed

眉间皱痕 提交于 2020-01-06 12:52:46

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!