我想出了我的问题的答案。我处理了form1上的所有事情。我创建了一个名为refreshData的方法,当我点击我的图标弹出form2时,我等待form2的Dialog Result OK,然后我调用了refreshData方法。希望这对其他人有帮助:
private void pictureBox1_Click(object sender, EventArgs e)
{
form2 box = new form2();
using (box)
{
box.ShowDialog();
if (box.DialogResult == DialogResult.OK)
{
refreshData();
}
box.Dispose();
}
}
private void refreshData()
{
ADODB.Recordset rs = new ADODB.Recordset();
ADODB.Connection adoCon = new ADODB.Connection();
adoCon.Open("put Connection String Here");
rs.Open("Put Select query Here",adoCon,ADODB.CursorTypeEnum.adOpenStatic,ADODB.LockTypeEnum.adLockOptimistic);
DataSet myDS = new DataSet();
OleDbDataAdapter da = new OleDbDataAdapter();
da.Fill(myDS, rs,"MyTable");
chkList1.DataSource = null;
chkList1.DataSource = myDS.Tables[0];
chkList1.DisplayMember = "Put Field to Display in CheckList here";
}