WinForm一些简单窗体程序

登录

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Windows1
{
    public partial class Main : Form
    {
        public Main()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string username = txtUserName.Text.Trim();
            string password = txtUserPwd.Text.Trim();

            if (username == "admin" && password == "123456")
            {
                MessageBox.Show("登录成功!");
            }
            else
            {
                MessageBox.Show("用户名或密码错误!");
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            foreach(Control item in this.Controls)
            {
                if(item is TextBox)
                {
                    item.Text = "";
                }
            }
        }
    }
}

注册

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Windows1
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }

        public bool IsNullOrEmpty(ControlBindingsCollection controls)
        {
            bool flag = false;
            foreach(Control item in controls)
            {
                if (string.IsNullOrEmpty(item.Text))
                {
                    flag = true;
                }
            }
            return flag;
        }
        private void button1_Click(object sender, EventArgs e)
        {
            bool flag = IsNullOrEmpty(this.Controls);
            if (flag == true)
            {
                MessageBox.Show("请填写好全部的信息!");
            }
            else
            {
                MessageBox.Show("恭喜你注册成功!");
            }
        } 

   }
}

简历编译器

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Windows1
{
    public partial class Form3 : Form
    {
        string file = "jianli.rtf";
        public Form3()
        {
            InitializeComponent();
        }

        private void btnLoad_Click(object sender, EventArgs e)
        {
            richTextBox1.LoadFile(file);
        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            richTextBox1.SaveFile(file);
        }

        private void btnCopy_Click(object sender, EventArgs e)
        {
            richTextBox1.Copy();
        }

        private void btnCut_Click(object sender, EventArgs e)
        {
            richTextBox1.Cut();
        }

        private void btnPaste_Click(object sender, EventArgs e)
        {
            richTextBox1.Paste();
        }

        private void btnBackColor_Click(object sender, EventArgs e)
        {
            //背景色更改为Blue
            richTextBox1.SelectionBackColor = Color.Blue;
        }

        private void btnColor_Click(object sender, EventArgs e)
        {
            //文字颜色更改为Brown
            richTextBox1.SelectionColor = Color.Brown;
        }

        private void btnFont_Click(object sender, EventArgs e)
        {
            //字体更改为20号黑体
            Font font = new Font("黑体", 20);
            richTextBox1.SelectionFont = font;
        }
    }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值