program.form1.dispose(bool): 没有找到合适的方法来重写
C#初学者不知道怎么回事按着书上来的usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentMo...
C# 初学者 不知道怎么回事
按着书上来的
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace ButtonControl
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
SaveFileDialog sa = new SaveFileDialog();
sa.Filter = "文本文件(.txt)|*.txt|C#文件(.cs)|*.cs|所有文件(*.*)|*.*";
sa.FilterIndex = 2;
sa.RestoreDirectory = true;
if (sa.ShowDialog() == DialogResult.OK)
{
string s = sa.FileName;
StreamWriter sw = File.AppendAllText(s);
sw.Write(this.richTextBox1.Text);
sw.Write("Hello World");
sw.Flush();
sw.Close();
}
}
private void button2_Click(object sender, EventArgs e)
{
this.richTextBox1.Text = "";//重置RichTextBox的内容
}
}
} 展开
按着书上来的
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace ButtonControl
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
SaveFileDialog sa = new SaveFileDialog();
sa.Filter = "文本文件(.txt)|*.txt|C#文件(.cs)|*.cs|所有文件(*.*)|*.*";
sa.FilterIndex = 2;
sa.RestoreDirectory = true;
if (sa.ShowDialog() == DialogResult.OK)
{
string s = sa.FileName;
StreamWriter sw = File.AppendAllText(s);
sw.Write(this.richTextBox1.Text);
sw.Write("Hello World");
sw.Flush();
sw.Close();
}
}
private void button2_Click(object sender, EventArgs e)
{
this.richTextBox1.Text = "";//重置RichTextBox的内容
}
}
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询