四章

1.  什么是MDI

2. 读取和 获取文件路径的几种方法

当需要快速输入信息时,有三种方法:

       1)     在key_down事件    if(e.keycode==keys.enter){this.textbox2.focus();}

       2)    private void textBox3_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                this.SelectNextControl(this.ActiveControl, true, true, true, true);
            }
        }

       3)

3.  窗体间传递复杂数据

     1)  构造传递    创建两个窗体,在form2重载构造函数,再在form1中调用

            public Form2(string msg)
        {
            InitializeComponent();
            label1.Text = msg;
        }

 private void button2_Click(object sender, EventArgs e)
        {
            Form2 f2 = new Form2(textBox5.Text.Trim());
            f2.Show();
        }

    2)  公有字段传递   在form2中写一个公共属性

public string Msg
        {
            get{     return label1.Text.Trim();}
            set{   label1.Text = value;}
        }
        public Form2(Form1 f1)  //重载
        {
            InitializeComponent();
            label1.Text = f1.MSG;   //把textBox5的值传给form2中的label1
        }

  form1 中public string MSG
        {
            get {  return textBox5.Text.Trim(); }
        }

    3)  又是委托与事件,很重要啊...

   

       

原文地址:https://www.cnblogs.com/dfg1609887373/p/7630086.html