RichTextBoxStreamType 列挙型

定義

RichTextBox コントロールにデータを読み込んで保存するために使用する入力ストリームと出力ストリームの種類を指定します。

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

フィールド

名前 説明
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メソッドを呼び出すときに使用します。

適用対象

こちらもご覧ください