sorry if the title is very confusing, but I’m not sure how to really ask this question. Right now, with my winform i am trying to make an edit function off of a double click event in my data grid view. When i double click a cell, another form pops up for the user to edit. What I want is when the user exits that form, it automatically updates what is in the dgv. I have a search function, and I just want to reuse it again after I exit that form. Here is some code…
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);
whats happening here is that when the form shows, it calls the btn_search_click before I even do anything to my other form. I was wondering if somehow I can pause the form or make it sleep until I quit the editForm function, and THEN call the search function. Please ask if you need more code or if you want to see the code from the other forms. Thanks!
Change
to
This will pause execution of the main form until editForm closes.