RichTextBoxStreamType 列舉

定義

指定 RichTextBox 控制項中用來載入和儲存資料之輸入和輸出資料流的類型。

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

欄位

PlainText 1

在物件連結與嵌入 (Object Linking and Embedding,OLE) 物件中包含空格的純文字資料流。

RichNoOleObjs 2

在 OLE 物件的位置中具有空格的 Rich Text 格式 (RTF) 資料流。 這個值只與 SaveFile(String) 控制項的 RichTextBox 方法一起使用時才有效。

RichText 0

Rich Text 格式 (RTF) 資料流。

TextTextOleObjs 3

具有 OLE 物件之文字表示的純文字資料流。 這個值只與 SaveFile(String) 控制項的 RichTextBox 方法一起使用時才有效。

UnicodePlainText 4

在物件連結與嵌入 (Object Linking and Embedding,OLE) 物件中包含空格的文字資料流。 文字以 Unicode 編碼。

範例

下列範例會將 的內容 RichTextBox 儲存到 ASCII 文字檔中。 此範例會 SaveFileDialog 使用 類別來顯示對話方塊,以要求使用者的路徑和檔案名。 然後,程式碼會將 控制項的內容儲存到該檔案。 此範例會使用這個版本的 SaveFile 方法來指定將檔案儲存為 ASCII 文字檔,而不是標準 RTF 格式。 本範例假設程式碼會放在具有 RichTextBox 名為 richTextBox1 的控制項的類別中 Form

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 時,請使用這個列舉的成員。

適用於

另請參閱