C#中用RichTextBox实现图文混排和保存的例子

C#中用RichTextBox实现图文混排和保存的例子
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using System.IO;

namespace test
{
	/// 
	/// Description of MainForm.
	/// 
	public partial class MainForm : Form
	{
		public MainForm()
		{
			//
			// The InitializeComponent() call is required for Windows Forms designer support.
			//
			InitializeComponent();
			
			//
			// TODO: Add constructor code after the InitializeComponent() call.
			//
		}
		
		void Button1Click(object sender, EventArgs e)
		{
			richTextBox1.Focus();
			richTextBox1.Select(0, richTextBox1.Rtf.Length);
		}
		
		void Button2Click(object sender, EventArgs e)
		{
			Clipboard.SetData(DataFormats.Rtf, richTextBox1.SelectedRtf);//
		}
		
		void Button4Click(object sender, EventArgs e)
		{
			Clipboard.SetData(DataFormats.Rtf, richTextBox1.SelectedRtf);//复制RTF数据到剪贴板

            richTextBox1.SelectedRtf="";//再把当前选取的RTF内容清除掉,当前就实现剪切功能了.
		}
		
		void Button3Click(object sender, EventArgs e)
		{
			richTextBox1.Focus();
			richTextBox1.Paste();//
		}
		
		void Button5Click(object sender, EventArgs e)
		{
			FileStream fs=new FileStream("F:\\ppp.rtf",FileMode.Create ,FileAccess.Write);
			richTextBox1.SaveFile(fs,RichTextBoxStreamType.RichText);
			fs.Close();
		}
	}
}

 C#中用RichTextBox实现图文混排和保存的例子_第1张图片

posted on 2016-12-12 23:04  向北方 阅读( ...) 评论( ...) 编辑 收藏

转载于:https://www.cnblogs.com/China3S/p/6166353.html

你可能感兴趣的:(C#中用RichTextBox实现图文混排和保存的例子)