RichTextBoxStreamType 枚举

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

**命名空间:**System.Windows.Forms
**程序集:**System.Windows.Forms(在 system.windows.forms.dll 中)

语法

声明
Public Enumeration RichTextBoxStreamType
用法
Dim instance As RichTextBoxStreamType
public enum RichTextBoxStreamType
public enum class RichTextBoxStreamType
public enum RichTextBoxStreamType
public enum RichTextBoxStreamType

成员

  成员名称 说明
PlainText 用空格代替对象链接与嵌入 (OLE) 对象的纯文本流。 
RichNoOleObjs 用空格代替 OLE 对象的丰富文本格式(RTF 格式)流。该值只在用于 RichTextBox 控件的 SaveFile 方法时有效。 
RichText RTF 格式流。 
TextTextOleObjs 具有 OLE 对象的文本表示形式的纯文本流。该值只在用于 RichTextBox 控件的 SaveFile 方法时有效。 
UnicodePlainText 包含用空格代替对象链接与嵌入 (OLE) 对象的文本流。该文本采用 Unicode 编码。 

备注

当调用 RichTextBox 控件的 LoadFileSaveFile 方法时使用此枚举的成员。

示例

下面的示例将 RichTextBox 的内容保存到 ASCII 文本文件中。此示例使用 SaveFileDialog 类显示一个向用户请求路径和文件名的对话框。然后代码将控件内容保存到该文件。此示例使用该版本的 SaveFile 方法指定将此文件保存为 ASCII 文本文件而不是标准 RTF 格式。此示例假定代码放置在 Form 类中,并且该类包含一个名为 richTextBox1RichTextBox 控件。

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
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:
   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.set_DefaultExt("*.rtf");
    saveFile1.set_Filter("RTF Files|*.rtf");

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

平台

Windows 98、Windows 2000 SP4、Windows CE、Windows Millennium Edition、Windows Mobile for Pocket PC、Windows Mobile for Smartphone、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition

.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求

版本信息

.NET Framework

受以下版本支持:2.0、1.1、1.0

请参见

参考

System.Windows.Forms 命名空间
RichTextBox 类
LoadFile
SaveFile