次の方法で共有


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 (Object Linking and Embedding) オブジェクトの代わりに空白が含まれているプレーン テキスト ストリーム。 
RichNoOleObjs OLE オブジェクトの代わりの空白を持つリッチ テキスト形式 (RTF: Rich Text Format) のストリーム。この値は、RichTextBox コントロールの SaveFile メソッドを使用する場合に限り有効です。 
RichText リッチ テキスト形式 (RTF) ストリーム。 
TextTextOleObjs OLE オブジェクトのテキスト表現を持つプレーン テキスト ストリーム。この値は、RichTextBox コントロールの SaveFile メソッドを使用する場合に限り有効です。 
UnicodePlainText OLE オブジェクトの代わりに空白が含まれているテキスト ストリーム。テキストは Unicode でエンコードされています。 

解説

この列挙体のメンバは、RichTextBox コントロールの LoadFile メソッドおよび SaveFile メソッドを呼び出すときに使用します。

使用例

RichTextBox の内容を ASCII テキスト ファイルに保存する例を次に示します。この例は、SaveFileDialog クラスを使用して、ファイルのパスと名前を指定するようにユーザーに要求するダイアログ ボックスを表示します。次に、コントロールの内容をユーザーが指定したファイルに保存します。この例では、このバージョンの SaveFile メソッドを使用し、ファイルを標準の RTF ファイルではなく ASCII テキスト ファイルとして保存するように指定しています。この例は、コードが richTextBox1 という名前の RichTextBox コントロールを保持する Form クラス内にあることを前提にしています。

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