RichTextBoxStreamType RichTextBoxStreamType RichTextBoxStreamType RichTextBoxStreamType Enum

定义

指定用于加载和保存 RichTextBox 控件数据的输入流和输出流的类型。Specifies the types of input and output streams used to load and save data in the RichTextBox control.

public enum class RichTextBoxStreamType
public enum RichTextBoxStreamType
type RichTextBoxStreamType = 
Public Enum RichTextBoxStreamType
继承
RichTextBoxStreamTypeRichTextBoxStreamTypeRichTextBoxStreamTypeRichTextBoxStreamType

字段

PlainText PlainText PlainText PlainText 1

用空格代替对象链接与嵌入 (OLE) 对象的纯文本流。A plain text stream that includes spaces in places of Object Linking and Embedding (OLE) objects.

RichNoOleObjs RichNoOleObjs RichNoOleObjs RichNoOleObjs 2

用空格代替 OLE 对象的丰富文本格式(RTF 格式)流。A Rich Text Format (RTF) stream with spaces in place of OLE objects. 该值只在用于 SaveFile(String) 控件的 RichTextBox 方法时有效。This value is only valid for use with the SaveFile(String) method of the RichTextBox control.

RichText RichText RichText RichText 0

RTF 格式流。A Rich Text Format (RTF) stream.

TextTextOleObjs TextTextOleObjs TextTextOleObjs TextTextOleObjs 3

具有 OLE 对象的文本表示形式的纯文本流。A plain text stream with a textual representation of OLE objects. 该值只在用于 SaveFile(String) 控件的 RichTextBox 方法时有效。This value is only valid for use with the SaveFile(String) method of the RichTextBox control.

UnicodePlainText UnicodePlainText UnicodePlainText UnicodePlainText 4

包含用空格代替对象链接与嵌入 (OLE) 对象的文本流。A text stream that contains spaces in place of Object Linking and Embedding (OLE) objects. 该文本采用 Unicode 编码。The text is encoded in Unicode.

示例

下面的示例的内容保存RichTextBox到 ASCII 文本文件。The following example saves the contents of the RichTextBox into an ASCII text file. 该示例使用SaveFileDialog类,以显示一个对话框以从用户请求的路径和文件名称。The example uses the SaveFileDialog class to display a dialog to request the path and file name from the user. 然后,代码将控件的内容保存到该文件。The code then saves the contents of the control to that file. 该示例使用此版本的SaveFile方法,以指定该文件将另存为 ASCII 文本文件,而不是标准的丰富文本格式。The example uses this version of the SaveFile method to specify that the file be saved as an ASCII text file instead of the standard Rich Text Format. 此示例假定将代码放置在Form类具有RichTextBox控件命名为richTextBox1This example assumes that the code is placed in a Form class that has a RichTextBox control named richTextBox1.

public:
   void SaveMyFile()
   {
      // Create a SaveFileDialog to request a path and file name to save to.
      SaveFileDialog^ saveFile1 = gcnew SaveFileDialog;
      
      // Initialize the SaveFileDialog to specify the RTF extension for the file.
      saveFile1->DefaultExt = "*.rtf";
      saveFile1->Filter = "RTF Files|*.rtf";
      
      // Determine if the user selected a file name from the saveFileDialog.
      if ( saveFile1->ShowDialog() == System::Windows::Forms::DialogResult::OK &&
         saveFile1->FileName->Length > 0 )
      {
         // Save the contents of the RichTextBox into the file.
         richTextBox1->SaveFile( saveFile1->FileName, RichTextBoxStreamType::PlainText );
      }
   }
public void SaveMyFile()
{
   // Create a SaveFileDialog to request a path and file name to save to.
   SaveFileDialog saveFile1 = new SaveFileDialog();

   // Initialize the SaveFileDialog to specify the RTF extension for the file.
   saveFile1.DefaultExt = "*.rtf";
   saveFile1.Filter = "RTF Files|*.rtf";

   // Determine if the user selected a file name from the saveFileDialog.
   if(saveFile1.ShowDialog() == System.Windows.Forms.DialogResult.OK &&
      saveFile1.FileName.Length > 0) 
   {
      // Save the contents of the RichTextBox into the file.
      richTextBox1.SaveFile(saveFile1.FileName, RichTextBoxStreamType.PlainText);
   }
}

Public Sub SaveMyFile()
    ' Create a SaveFileDialog to request a path and file name to save to.
    Dim saveFile1 As New SaveFileDialog()
    
    ' Initialize the SaveFileDialog to specify the RTF extension for the file.
    saveFile1.DefaultExt = "*.rtf"
    saveFile1.Filter = "RTF Files|*.rtf"
    
    ' Determine if the user selected a file name from the saveFileDialog.
    If (saveFile1.ShowDialog() = System.Windows.Forms.DialogResult.OK) _
        And (saveFile1.FileName.Length) > 0 Then
    
        ' Save the contents of the RichTextBox into the file.
        richTextBox1.SaveFile(saveFile1.FileName, _
            RichTextBoxStreamType.PlainText)
    End If
End Sub

注解

在调用时使用此枚举成员LoadFileSaveFile方法的RichTextBox控件。Use the members of this enumeration when calling the LoadFile and SaveFile methods of the RichTextBox control.

适用于

另请参阅