RichTextBoxStreamType 枚举

定义

指定用于在 RichTextBox 控件中加载和保存数据的输入和输出流的类型。

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

字段

名称 说明
RichText 0

格式文本格式 (RTF) 流。

PlainText 1

一个纯文本流,其中包含对象链接和嵌入 (OLE) 对象位置中的空格。

RichNoOleObjs 2

格式文本格式(RTF)流,包含空格代替 OLE 对象。 此值仅可用于 SaveFile(String) 控件的方法 RichTextBox

TextTextOleObjs 3

包含 OLE 对象的文本表示形式的纯文本流。 此值仅可用于 SaveFile(String) 控件的方法 RichTextBox

UnicodePlainText 4

一个文本流,包含空格代替对象链接和嵌入 (OLE) 对象。 文本在 Unicode 中编码。

示例

以下示例将该文件 RichTextBox 的内容保存到 ASCII 文本文件中。 该示例使用 SaveFileDialog 类显示对话框来请求用户的路径和文件名。 然后,代码将控件的内容保存到该文件。 该示例使用此版本的 SaveFile 方法指定将文件保存为 ASCII 文本文件,而不是标准格式格式。 此示例假定代码放置在名为 <a0/a0> 的控件的类中。

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

注解

调用 LoadFile 控件和 SaveFile 方法 RichTextBox 时,请使用此枚举的成员。

适用于

另请参阅