通用文本提示对话框窗体支持保存文本文件|C/S框架网
通用文本提示对话框窗体支持保存文本文件|C/S框架网
frmPromptMemo.cs下载:
C# Code:
public partial class frmPromptMemo : Form
{
private frmPromptMemo()
{
InitializeComponent();
}
public static void Execute(string content)
{
frmPromptMemo form = new frmPromptMemo();
form.txtContent.Text = content;
form.ShowDialog();
}
private void btnClose_Click(object sender, EventArgs e)
{
this.Close();
}
private void btnSave_Click(object sender, EventArgs e)
{
SaveFileDialog dlg = new SaveFileDialog();
dlg.Filter = "文本文件(*.txt)|*.txt";
if (dlg.ShowDialog() == DialogResult.OK)
{
try
{
File.WriteAllLines(dlg.FileName, txtContent.Lines, Encoding.UTF8);
Msg.ShowInformation("保存成功!");
}
catch (Exception ex)
{
Msg.Warning(ex.Message);
}
}
}
}
//来源:C/S框架网(www.csframework.com) QQ:23404761
public partial class frmPromptMemo : Form
{
private frmPromptMemo()
{
InitializeComponent();
}
public static void Execute(string content)
{
frmPromptMemo form = new frmPromptMemo();
form.txtContent.Text = content;
form.ShowDialog();
}
private void btnClose_Click(object sender, EventArgs e)
{
this.Close();
}
private void btnSave_Click(object sender, EventArgs e)
{
SaveFileDialog dlg = new SaveFileDialog();
dlg.Filter = "文本文件(*.txt)|*.txt";
if (dlg.ShowDialog() == DialogResult.OK)
{
try
{
File.WriteAllLines(dlg.FileName, txtContent.Lines, Encoding.UTF8);
Msg.ShowInformation("保存成功!");
}
catch (Exception ex)
{
Msg.Warning(ex.Message);
}
}
}
}
//来源:C/S框架网(www.csframework.com) QQ:23404761
使用方法:
C# Code:
frmPromptMemo.Execute("您的内容");
//来源:C/S框架网(www.csframework.com) QQ:23404761
frmPromptMemo.Execute("您的内容");
//来源:C/S框架网(www.csframework.com) QQ:23404761
本源码适用版本:CSFrameworkV4~V5所有版本。
frmPromptMemo.cs下载:
版权声明:本文为开发框架文库发布内容,转载请附上原文出处连接
NewDoc C/S框架网