private void textBox5_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter & xianz == false)
            {
                chaxin chaxin = new chaxin(this);
                chaxin.Show();
                Program.tiaojian.tj = textBox5.Text;
                textBox5.Text = null;
                xianz = true;
            }        }
打开的子窗体
  private void chaxin_Load(object sender, EventArgs e)
        {
            
            tiao = Program.tiaojian.tj;
            try
            {
                string sqlStr = "server=SERVER;database=DianZiBingLi;uid=sa;password=wzh1103";
                SqlConnection con = new SqlConnection(sqlStr);
                con.Open();
                string sql = string.Format("select ID, MC, BM  from ICDM where ZJM like '%" + tiao.Trim() + "%'");
                //SqlCommand sqlCom = new SqlCommand(sql, con);
                SqlDataAdapter da = new SqlDataAdapter(sql, con);
                DataSet ds = new DataSet();
                da.Fill(ds);
                DataTable dt;
                dt = ds.Tables[0].Copy();
                dataGridView1.DataSource = dt;
                
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);            }
        }存在问题是;
第一次打敲回车后都会提示“未将对象引用设置到对象的实例”
当继续敲回车后会打开一空白的子窗体,假如在继续敲回车,则程序会自动关闭。
假如用鼠标把打开的空白子窗体关闭后,在重操作又是正常的。请大家帮忙看看到底问题出在什么地方!!谢谢