RichTextBoxStreamType Enum
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Specifies the types of input and output streams used to load and save data in the RichTextBox control.
public enum class RichTextBoxStreamType
public enum RichTextBoxStreamType
type RichTextBoxStreamType =
Public Enum RichTextBoxStreamType
- Inheritance
Name | Value | Description |
---|---|---|
RichText | 0 | A Rich Text Format (RTF) stream. |
PlainText | 1 | A plain text stream that includes spaces in places of Object Linking and Embedding (OLE) objects. |
RichNoOleObjs | 2 | A Rich Text Format (RTF) stream with spaces in place of OLE objects. This value is only valid for use with the SaveFile(String) method of the RichTextBox control. |
TextTextOleObjs | 3 | A plain text stream with a textual representation of OLE objects. This value is only valid for use with the SaveFile(String) method of the RichTextBox control. |
UnicodePlainText | 4 | A text stream that contains spaces in place of Object Linking and Embedding (OLE) objects. The text is encoded in Unicode. |
The following example saves the contents of the RichTextBox into an ASCII text file. The example uses the SaveFileDialog class to display a dialog to request the path and file name from the user. The code then saves the contents of the control to that file. The example uses this version of the SaveFile method to specify that the file be saved as an ASCII text file instead of the standard Rich Text Format. This example assumes that the code is placed in a Form class that has a RichTextBox control named 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
Use the members of this enumeration when calling the LoadFile and SaveFile methods of the RichTextBox control.
Produit | Versions |
---|---|
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
Windows Desktop | 3.0, 3.1, 5, 6, 7, 8, 9 |
Commentaires sur .NET
.NET est un projet open source. Sélectionnez un lien pour fournir des commentaires :