表单关闭时无法更新或刷新我的数据网格

时间:2017-02-26 05:56:17

标签: c# datagrid

只要frmBorrow关闭

,这是我的代码
    void borrowClose() 
    {
      frmBorrow br1 = new frmBorrow(this);
      br1.FormClosing += br1_FormClosing;
    }

    void br1_FormClosing(object sender, FormClosingEventArgs e)
    {
      LoadTransactions();
    }

    void LoadTransactions()
    {
            cfgotcall.tether(settings);
            string sql = "SELECT * FROM tbltransactionbooks WHERE fBorrowDate LIKE '%" + txtSEARCH.Text.Trim() + "%'";
            cfgotcall.engageQuery(sql);
            unitbl = cfgotcall.tbl;

            sql = "SELECT fBarcodeNo AS 'Barcode No',fBookTitle AS 'Book',fStudent AS 'Student',fIDStudent AS 'Student ID',fStatus AS 'Status',fCourse AS 'Course',fBorrowDate AS 'Date Borrowed',fReturnDate AS 'Due Date',fAuthor AS 'Author',fAccNo AS 'Accession No.',fCallNo AS 'Call No.' FROM tbltransactionbooks WHERE fBorrowDate LIKE '%"
               + txtSEARCH.Text.Trim() + "%'";
            cfgotcall.engageQuery(sql);
            dgvDISPLAY.DataSource = cfgotcall.tbl;
            dgvDISPLAY.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
            cfgotcall.untether();
     }

0 个答案:

没有答案