WindowsForm 入门

namespace WindowsFormsApp1
{

    public partial class Form1 : Form
    {
        public Form1()// 构造函数  //与类名相同
        {
            InitializeComponent();
        }

        //private void button1_Click(object sender, EventArgs e)
        //{
        //    button1.Size = new Size(200, 200);
        //    button1.SendToBack();//置于底层

        //    button1.Location = new System.Drawing.Point(180, 200);
        //    button1.BringToFront();//至于顶层
        //}

        private void label1_Click(object sender, EventArgs e)
        {
            MessageBox.Show("你真厉害,竟然点击到了我!");

        }

        private void label1_MouseEnter(object sender, EventArgs e)
        {
            int x = this.ClientSize.Width - label1.Width;
            int y = this.ClientSize.Height - label1.Height;
            Random r = new Random();
            label1.Location = new Point(r.Next(0, x + 1), r.Next(0, y + 1));

        }

        private void Form1_Load(object sender, EventArgs e)
        {
            Text = "恭喜你!!";
            Try.myform1=this;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Form2 myform2 = new Form2();
            myform2.Show();
        }
    }

 

namespace WindowsFormsApp1
{
    public partial class Form3 : Form
    {
        public Form3()
        {
            InitializeComponent();
           
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Text = "点击领取";
            MessageBox.Show("逗你玩","这你都相信?");
            //静态全局共享 静态存储 全局共享
            Try.myform1.Close();
        }

        private void Form3_Load(object sender, EventArgs e)
        {
            Text = "你中了特等奖";
        }
    }

 


namespace WindowsFormsApp1
{
    public static class Try
    {
        public static Form1 myform1;
    }
}

 

你可能感兴趣的:(C#,笔记)