1、在程序加载的时候,取消文本框的自动换行,以及让两个按钮和文本框隐藏。
2、点击登陆,判断是否登陆成功。
3、自动换行功能。 
4、保存文本到一个指定目录下。

public partial class Form1 : Form{public Form1(){InitializeComponent();}private void textBox1_TextChanged(object sender, EventArgs e){}private void Form1_Load(object sender, EventArgs e){txtWords.WordWrap = false;btnWordWarp.Visible = false;btnSave.Visible = false;txtWords.Visible = false;btnClose.Visible = false;}/// <summary>/// ,用户点击登陆,判断是否登陆成功/// </summary>/// <param name="sender"></param>/// <param name="e"></param>private void btnLogin_Click(object sender, EventArgs e){string name = txtName.Text.Trim();string pwd = txtPwd.Text;if (name == "admin" && pwd == "888888"){MessageBox.Show("欢迎使用 <微咲> 简单记事本!");btnWordWarp.Visible = true;btnSave.Visible = true;txtWords.Visible = true;btnClose.Visible = true;lblName.Visible = false;lblPwd.Visible = false;txtName.Visible = false;txtPwd.Visible = false;btnLogin.Visible = false;btnReset.Visible = false;btnClose1.Visible = false;}else //登陆失败{MessageBox.Show("用户名或密码错误,请重新登陆!");//用户输入失败后,清空两个文本框txtName.Clear();txtPwd.Clear();//让焦点到TxtName中txtName.Focus();}}/// <summary>/// 用户点击重置/// </summary>/// <param name="sender"></param>/// <param name="e"></param>private void btnReset_Click(object sender, EventArgs e){//用户点击重置后,清空两个文本框txtName.Clear();txtPwd.Clear();//让焦点到TxtName中txtName.Focus();}/// <summary>/// 自动换行/// </summary>/// <param name="sender"></param>/// <param name="e"></param>private void btnWordWarp_Click(object sender, EventArgs e){//当前是否自动换行if (btnWordWarp.Text=="自动换行"){//取消自动换行txtWords.WordWrap = true;btnWordWarp.Text = "取消自动换行";}else if(btnWordWarp.Text == "取消自动换行"){txtWords.WordWrap = false;btnWordWarp.Text = "自动换行";}}/// <summary>/// 保存文本/// </summary>/// <param name="sender"></param>/// <param name="e"></param>private void btnSave_Click(object sender, EventArgs e){using (FileStream fsWrite = new FileStream(@"C:\Users\46124\Desktop\记事本.txt", FileMode.Append, FileAccess.Write)){string userInput = txtWords.Text.Trim()+"\n";byte[] buffer = System.Text.Encoding.Default.GetBytes(userInput);fsWrite.Write(buffer, 0, buffer.Length);}MessageBox.Show("保存成功");}private void btnClose_Click(object sender, EventArgs e){this.Close();}private void btnClose1_Click(object sender, EventArgs e){this.Close();}}
