RichTextBoxStreamType 列舉

定義

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

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

欄位

名稱 Description
RichText 0

一種富文本格式(RTF)串流。

PlainText 1

一個包含物件連結與嵌入(OLE)物件位置空格的純文字串流。

RichNoOleObjs 2

一種以空格取代 OLE 物件的富文字格式(RTF)串流。 此值僅適用於控制 SaveFile(String) 方法 RichTextBox

TextTextOleObjs 3

一個純文字串流,包含 OLE 物件的文字表示。 此值僅適用於控制 SaveFile(String) 方法 RichTextBox

UnicodePlainText 4

一個包含空格的文字串流,取代了物件連結與嵌入(OLE)物件。 文本以Unicode編碼。

範例

以下範例將 RichTextBox 的內容儲存為 ASCII 文字檔。 範例中使用 該 SaveFileDialog 類別來顯示一個對話框,向使用者請求路徑與檔案名稱。 程式碼會將控制項的內容儲存到該檔案中。 範例中使用此版本 SaveFile 的方法,指定檔案儲存為 ASCII 文字檔,而非標準的富文本格式。 此範例假設程式碼被放置在 Form 一個名為 RichTextBox 的控制 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

備註

呼叫 LoadFile 控制的 和 SaveFile 方法 RichTextBox 時,請使用此列舉的成員。

適用於

另請參閱