zoukankan      html  css  js  c++  java
  • C#中用RichTextBox实现图文混排和保存的例子

    using System;
    using System.Collections.Generic;
    using System.Drawing;
    using System.Windows.Forms;
    using System.IO;
    
    namespace test
    {
    	/// <summary>
    	/// Description of MainForm.
    	/// </summary>
    	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();
    		}
    	}
    }
    

     

  • 相关阅读:
    java读取excel文件内容
    JavaScript函数写法整理
    Redis命令
    Redis简单入门
    Redis介绍
    NodeJS代码调试
    React组件生命周期
    解决swiper动态改变数据后分页混乱问题
    [LeetCode] 343. Integer Break
    [LeetCode] 304. Range Sum Query 2D
  • 原文地址:https://www.cnblogs.com/China3S/p/6166353.html
Copyright © 2011-2022 走看看