RichTextBoxStreamType Enum

Definition

Anger vilka typer av indata- och utdataströmmar som används för att läsa in och spara data i RichTextBox kontrollen.

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

Fält

Name Värde Description
RichText 0

En RTF-ström (RtF).

PlainText 1

En oformaterad textström som innehåller blanksteg i platser för objektlänkning och inbäddningsobjekt (OLE).

RichNoOleObjs 2

En RTF-ström (RTF) med blanksteg i stället för OLE-objekt. Det här värdet är endast giltigt för användning med SaveFile(String) kontrollens RichTextBox metod.

TextTextOleObjs 3

En oformaterad textström med en textrepresentation av OLE-objekt. Det här värdet är endast giltigt för användning med SaveFile(String) kontrollens RichTextBox metod.

UnicodePlainText 4

En textström som innehåller blanksteg i stället för objektlänknings- och inbäddningsobjekt (OLE). Texten kodas i Unicode.

Exempel

I följande exempel sparas innehållet RichTextBox i en ASCII-textfil. I exemplet används SaveFileDialog klassen för att visa en dialogruta för att begära sökvägen och filnamnet från användaren. Koden sparar sedan innehållet i kontrollen i filen. I exemplet används den SaveFile här versionen av metoden för att ange att filen ska sparas som en ASCII-textfil i stället för det vanliga RTF-formatet. Det här exemplet förutsätter att koden placeras i en Form klass som har en RichTextBox kontroll med namnet 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

Kommentarer

Använd medlemmarna i den här uppräkningen när du anropar LoadFile kontrollens SaveFile metoder och RichTextBox .

Gäller för

Se även