日期:2014-05-17  浏览次数:21298 次

winform窗体切换
父窗体点击btnAdd打开窗体A,在窗体A中完成操作后(点击确定按钮),返回数据,并打开B窗体

我的实现代码:
A窗体:
private void btnOK_Click(object sender, EventArgs e)
        {
            if (!DoValid()) return;
            string str = "";
            foreach (string strSpNo in strSpPlanArr)
            {
                str = str + strSpNo + ",";
            }

            str = str.TrimEnd(',');
            PlanSelectedEvent(this, new PlanSelectedEventArgs { spPlanNoList = str });
        }

父窗体:

 private void btnAdd_Click(object sender, EventArgs e)
        {
            frmPlanSelect.Width = 175;
            frmPlanSelect.ReferForm = this;
            frmPlanSelect.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
            frmPlanSelect.MaximizeBox = false;
            frmPlanSelect.ShowDialog();
        }

        private void onPlanSelected(object sender, PlanSelectedEventArgs e)
        {
            strSpNoList = e.spPlanNoList;
            frmPlanSelect.Close();
            ShowEditForm();
        }


        /// <summary>
        /// 显示编辑页
        /// </summary>
        /// <param name="iSpID"></param>