登录
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;
}
}
}