就像扫雷那样在自定义后改变开始的页面
我在form2里 用 form1 F1=new form1(); F1.Show();但是会新打开一个form1窗口变成2个。。
问下要怎么弄?

解决方案 »

  1.   


    Form2 f2 = new Form2();
     private void button1_Click(object sender, EventArgs e)
      {
      f2.MyA+= new Form2.AA(B);
      f2.Show();
      }
    void B(string str){}public delegate void AA(string str);
    public event AA MyA;
     private void button1_Click(object sender, EventArgs e)
      {
      this.MyA();
      }
      

  2.   


    //Form1
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;namespace TestShow
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
            public Form1(string str)
            {
                InitializeComponent();
                this.label1.Text = str;
            }
         private void button2_Click(object sender, EventArgs e)
            {
                Form2 fr2 = new Form2();
                fr2.Show();
                this.Visible = false;
            }
    //=========================
    //Form2
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;namespace TestShow
    {
        public partial class Form2 : Form
        {
            public Form2()
            {
                InitializeComponent();
            }
            private void button1_Click(object sender, EventArgs e)
            {
                Form1 fr1 = new Form1(textBox1.Text);
                fr1.Show();
                this.Visible = false;
            }
        }
    }
      

  3.   

    伪代码//form1
    public set(int a)
    {
        //here you can set this form,such as
        this.width=a;
    }// in another function
    form2 f2=new form2();
    f2.tag=this;
    f2.show();
    //---------
    //form2form1 f1=(form1)this.tag;
    f1.set(50);