RichTextBoxStreamType Énumération

Définition

Spécifie les types de flux d'entrée et de sortie utilisés pour charger et enregistrer les données dans le contrôle RichTextBox.

public enum class RichTextBoxStreamType
public enum RichTextBoxStreamType
type RichTextBoxStreamType = 
Public Enum RichTextBoxStreamType
Héritage
RichTextBoxStreamType

Champs

PlainText 1

Flux de texte brut où des espaces remplacent les objets OLE.

RichNoOleObjs 2

Flux RTF avec des espaces à la place des objets OLE. Cette valeur peut uniquement être utilisée avec la méthode SaveFile(String) du contrôle RichTextBox.

RichText 0

Flux RTF.

TextTextOleObjs 3

Flux de texte brut avec une représentation textuelle des objets OLE. Cette valeur peut uniquement être utilisée avec la méthode SaveFile(String) du contrôle RichTextBox.

UnicodePlainText 4

Flux de texte où des espaces remplacent les objets OLE. Le texte est encodé en Unicode.

Exemples

L’exemple suivant enregistre le contenu du RichTextBox fichier texte ASCII. L’exemple utilise la SaveFileDialog classe pour afficher une boîte de dialogue pour demander le chemin d’accès et le nom de fichier de l’utilisateur. Le code enregistre ensuite le contenu du contrôle dans ce fichier. L’exemple utilise cette version de la SaveFile méthode pour spécifier que le fichier doit être enregistré en tant que fichier texte ASCII au lieu du format de texte enrichi standard. Cet exemple suppose que le code est placé dans une Form classe qui a un RichTextBox contrôle nommé 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

Remarques

Utilisez les membres de cette énumération lors de l’appel des méthodes et SaveFile des LoadFile méthodes du RichTextBox contrôle.

S’applique à

Voir aussi