WinForm ReturnFocus/ Pause Form event?

本文关键字:event Form Pause ReturnFocus WinForm | 更新日期: 2023-09-27 18:05:22

抱歉,如果标题很混乱,但我不确定如何真正问这个问题。现在,我的winform我试图使编辑功能的双击事件在我的数据网格视图。当我双击一个单元格时,会弹出另一个表单供用户编辑。我想要的是当用户退出表单时,它会自动更新dgv中的内容。我有一个搜索函数,我想在退出表单后再次使用它。下面是一些代码…

        if (combo_View.Text == "Orders")
        {
            DateTime date = new DateTime();
            string PO, item, repack, UPS, wrapping, usage, price, notes, customerName;
            int inOrder, outOrder, oid, palletNum, vid, cid;
            double weight, cf;
            string myIndex = dgv_DataLookup.CurrentCell.OwningRow.Cells[16].Value.ToString();
            DataSet editSet = new DataSet();
            da.SelectCommand = new OleDbCommand("SELECT oid, orderDate, PO, itemNum, InOrder, OutOrder, Repack, UPS, Pallets, PalletWrap, PalletUse, UPSAmount, LBS, CF, NoteOrder, VendorID, CustomerID, CustomerName FROM TestQuery WHERE oid = @oid", cs);
            da.SelectCommand.Parameters.Add("@oid", OleDbType.Integer).Value = myIndex;
            editSet.Clear();
            da.Fill(editSet);
            oid = int.Parse(editSet.Tables[0].Rows[0][0].ToString());
            date = DateTime.Parse(editSet.Tables[0].Rows[0][1].ToString());
            PO = editSet.Tables[0].Rows[0][2].ToString();
            item = editSet.Tables[0].Rows[0][3].ToString();
            inOrder = int.Parse(editSet.Tables[0].Rows[0][4].ToString());
            outOrder = int.Parse(editSet.Tables[0].Rows[0][5].ToString());
            repack = editSet.Tables[0].Rows[0][6].ToString();
            UPS = editSet.Tables[0].Rows[0][7].ToString();
            palletNum = int.Parse(editSet.Tables[0].Rows[0][8].ToString());
            wrapping = editSet.Tables[0].Rows[0][9].ToString();
            usage = editSet.Tables[0].Rows[0][10].ToString();
            price = editSet.Tables[0].Rows[0][11].ToString();
            weight = double.Parse(editSet.Tables[0].Rows[0][12].ToString());
            cf = double.Parse(editSet.Tables[0].Rows[0][13].ToString());
            notes = editSet.Tables[0].Rows[0][14].ToString();
            vid = int.Parse(editSet.Tables[0].Rows[0][15].ToString());
            cid = int.Parse(editSet.Tables[0].Rows[0][16].ToString());
            customerName = editSet.Tables[0].Rows[0][17].ToString();
            Edit editForm = new Edit("ORDER", oid, date, PO, item, inOrder, outOrder, repack, UPS, palletNum, wrapping, usage, price, weight, cf, notes, vid, cid, customerName);
            editForm.Show();
            btn_Search_Click(null, null);

这里发生的事情是,当表单显示时,它调用btn_search_click甚至在我对另一个表单做任何事情之前。我想知道我是否可以暂停表单或使其睡眠,直到我退出editForm函数,然后调用搜索函数。请询问您是否需要更多的代码,或者如果您想从其他形式看到的代码。谢谢!

WinForm ReturnFocus/ Pause Form event?

变化

editForm.Show();

editForm.ShowDialog();

这将暂停主表单的执行,直到editForm关闭。