RichTextBoxStreamType Enum

Definisi

Menentukan jenis aliran input dan output yang digunakan untuk memuat dan menyimpan data dalam kontrol RichTextBox.

public enum class RichTextBoxStreamType
public enum RichTextBoxStreamType
type RichTextBoxStreamType = 
Public Enum RichTextBoxStreamType
Warisan
RichTextBoxStreamType

Bidang

Nama Nilai Deskripsi
RichText 0

Aliran Rich Text Format (RTF).

PlainText 1

Aliran teks biasa yang menyertakan spasi di tempat objek Object Linking and Embedding (OLE).

RichNoOleObjs 2

Aliran Rich Text Format (RTF) dengan spasi sebagai pengganti objek OLE. Nilai ini hanya valid untuk digunakan dengan SaveFile(String) metode RichTextBox kontrol.

TextTextOleObjs 3

Aliran teks biasa dengan representasi tekstual objek OLE. Nilai ini hanya valid untuk digunakan dengan SaveFile(String) metode RichTextBox kontrol.

UnicodePlainText 4

Aliran teks yang berisi spasi sebagai pengganti objek Object Linking and Embedding (OLE). Teks dikodekan dalam Unicode.

Contoh

Contoh berikut menyimpan konten RichTextBox ke dalam file teks ASCII. Contoh menggunakan SaveFileDialog kelas untuk menampilkan dialog untuk meminta jalur dan nama file dari pengguna. Kode kemudian menyimpan konten kontrol ke file tersebut. Contoh menggunakan versi SaveFile metode ini untuk menentukan bahwa file disimpan sebagai file teks ASCII alih-alih Format Teks Kaya standar. Contoh ini mengasumsikan bahwa kode ditempatkan di Form kelas yang memiliki RichTextBox kontrol bernama 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

Keterangan

Gunakan anggota enumerasi ini saat memanggil LoadFile metode SaveFile dan RichTextBox kontrol.

Berlaku untuk

Lihat juga