none
读入程序 RRS feed

  • 问题

  • 我想尝试用一定的方法建立读入的对话框,但是程序的存在问题。想请问以下如何修改,应该用什么数据模式?

    一直报错的语句如下所示。

    richTextBox.Rtf = "";

    可能和这个语句有关,我不确定是需要的是不是这个数据类型。

            private RichTextBox richTextBox;

    以下是我的程序的一部分。

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Forms;
    
    namespace WindowsFormsApplication5
    {
        public partial class main : Form
        {
            public main()
            {
                InitializeComponent();
            }
    
            private string documentTitle;
            private RichTextBox richTextBox;
    
            private void eidtToolStripMenuItem_Click(object sender, EventArgs e)
            {
                
            }
    
            private void toolStripMenuItem1_Click(object sender, EventArgs e)
            {
                richTextBox.Rtf = "";
                documentTitle = "";
                
               
            }
    
            private void openMenuItem_Click(object sender, EventArgs e)
            {
                openFileDialog1.Title = "Open File";
                openFileDialog1.Filter = "Rick Text Files (*.rtf)|*.rtf|All Files (*.*)|*.*";
                openFileDialog1.FileName = "";
                openFileDialog1.FilterIndex = 0;
    
                openFileDialog1.InitialDirectory = "MyDocuments";
    
                openFileDialog1.CheckFileExists = true;
                openFileDialog1.CheckPathExists = true;
    
                if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    richTextBox.SaveFile(saveFileDialog1.FileName, RichTextBoxStreamType.RichText);
                    documentTitle = saveFileDialog1.FileName;
    
                }
            }
        }
    }

    谢谢!

    2014年4月19日 10:01

答案