第一章

 9:37:19
大客官 2018/2/27/周二 9:37:19

第一章

1.创建windows窗体应用程序。
2.Form1.cs窗体文件,程序员对窗体编写的代码一般都存放在这个文件中
3.Form1.Designer.ce:窗体设计文件,其中的代码是有由VisUal Studio自动生成的,一般不需要修改
4.Form1.resx:资源文件,用来配置当前窗体所使用的字符串,图片等资源
5.Program.cs:主程序文件,其中包含程序入口的Main()方法。
6.Label 创建属性  TextBox 创建文本框  ComboBox 创建自定义文本框  Butto 创建按钮
7.Click 查找属性 
             //new 个对象
8.          Form3 cc = new Form3();
                      //左边带有值的属性付给 共有的变量   
            cc.name 

 = textBox1.Text;
            cc.Pwd = txtBox.Text;
            cc.Show();
            this.Hide(); 


                 private void Form3_Load(object sender, EventArgs e)
        {
            lblcnm.Text =lblcnm.Text+ name;
            lblTt.Text = lblTt.Text + Pwd;
        }



              DialogResult result= MessageBox.Show("是否取消!?","提示~!@#¥%……&*()――+",MessageBoxButtons.YesNo,MessageBoxIcon.Error);
           if (result == DialogResult.No 

)
           {
               this.Close();
           }
9.Trim()去空格     MessageBox.Show("") 按取消的提示语句    .Focus()就是获得焦点的意思比如:function A(){    if(txtUser.text.value==null){         alert("请输入用户名");         txtUser.focus();         return;}意思就是当你没有输入txtUser文本框中的内容时,自动获得此文本框的焦点,然手光标移动到此文本框中
10.MessageBoxButtons.(按钮形式)  MessageBoxIcon.(报错图标)
11.State 状态   object 可以转换成任何类型.所以适用于所有类型值的比较.
                                    本章总结
11.使用窗体的属性设计窗体,窗体常用的属性有FormBorderStyle(窗体形状 调大调小)  StartPosition(窗体的位置)  WindowState(窗体的大小)等。
12.使用标签(Label)(lbl)  文本框(TextBox)(txt)  组合框(ComboBox)(cob) 按钮(Button)(btn) 设计窗体界面。这些控件有通常有属性  如Name  Text  Enable  也有各自特有大的属性。
13.编写事件处理程序:即针对用户触发的事件编写合适的处理方式。
14.使用MessageBox弹出四种消息框 使用DialogResult获得消息框的返回值。
15.使用窗体Show()方法和Hide()方法实现窗体的显示和隐藏。
16.结合ADO.NET 

和WinForms编写简单的数据库处理程序。
17.在窗体定义字段 实现窗体的数据传递。。



                                                 猜数小游戏
public partial class Form1 : Form
    {
       
        int d;//在控制台输入的数
        int h;//返回值强转 h
        int c;//计算错误次数
        public Form1()
        {
            InitializeComponent();
        }
        public int show() 
        {
            Random r = new Random();//new一个随机数
            int num= r.Next(1,100);//返回一个1~100的整数 (不包括100)
            txtZai.Text = Convert.ToString(num);
           return num;
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            h = show(); 
        }

        private void btnNew_Click(object sender, EventArgs e)
        {
            btnCk.Enabled = true;//开始能点击!!
        }
        private void btnCk_Click(object sender, EventArgs e)
        {
            d = int.Parse(txtSh.Text);
            if (d == h)
            {
                MessageBox.Show("恭喜你猜对了 奖励老婆一个!!!一共猜了" + c, "温馨提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk);
            }
            else if (h > d)
            {
                MessageBox.Show("小了! 在猜~", "温馨提示", MessageBoxButtons.OKCancel);
                c++;
            }
            else if (h < d)
            {
                MessageBox.Show("大了! 在猜~", "温馨提示", MessageBoxButtons.OKCancel);
                c++;
            }
        }
    }
}

原文地址:https://www.cnblogs.com/SFHa/p/8477153.html