《记事本程序设计.ppt》由会员分享,可在线阅读,更多相关《记事本程序设计.ppt(53页珍藏版)》请在第壹文秘上搜索。
1、 if (this.istext=false) /判断文本框是否改变 openFileDialog1.Filter = 文本文档(*.txt)|*.txt|所有文件(*.*)|*.*; openFileDialog1.FileName = *.txt; openFileDialog1.Title = 打开文件; if (openFileDialog1.ShowDialog() = DialogResult.OK) filename = openFileDialog1.FileName; string filename2 = filename.Split(); /只取文件名, StreamRea
2、der sr = new StreamReader(openFileDialog1.FileName, Encoding.Default); textBox1.Text = sr.ReadToEnd(); sr.Close(); this.istext = false; this.Text = filename2filename2.Length-1+ - 记事本; else DialogResult dr=MessageBox.Show(文本已更改,是否保存?,提示,MessageBoxButtons.YesNoCancel,MessageBoxIcon.Warning); if (dr=DialogResult.Yes) / MessageBox.Show(dr.ToString(); this.保存ToolStripMenuItem.PerformClick(); this.打开ToolStripMenuItem.PerformClick(); else if (dr = DialogResult.No) this.istext = false; this.打开ToolStripMenuItem.PerformClick();