RichTextBox.SelectedText Vlastnost
Definice
Důležité
Některé informace platí pro předběžně vydaný produkt, který se může zásadně změnit, než ho výrobce nebo autor vydá. Microsoft neposkytuje žádné záruky, výslovné ani předpokládané, týkající se zde uváděných informací.
Získá nebo nastaví vybraný text v rámci RichTextBox.
public:
virtual property System::String ^ SelectedText { System::String ^ get(); void set(System::String ^ value); };
[System.ComponentModel.Browsable(false)]
public override string SelectedText { get; set; }
[<System.ComponentModel.Browsable(false)>]
member this.SelectedText : string with get, set
Public Overrides Property SelectedText As String
Hodnota vlastnosti
Řetězec, který představuje vybraný text v ovládacím prvku.
- Atributy
Příklady
Následující příklad kódu ukazuje, jak použít SelectionBullet vlastnost s SelectionFont, SelectedTexta SelectionColor vlastnosti vytvořit seznam s odrážkami v ovládacím RichTextBox prvku. Tento příklad vyžaduje vytvoření RichTextBox ovládacího prvku pojmenovaného richTextBox1
ve formuláři.
private:
void WriteTextToRichTextBox()
{
// Clear all text from the RichTextBox;
richTextBox1->Clear();
// Set the font for the opening text to a larger Arial font;
richTextBox1->SelectionFont = gcnew System::Drawing::Font( "Arial",16 );
// Assign the introduction text to the RichTextBox control.
richTextBox1->SelectedText = "The following is a list of bulleted items: \n";
// Set the Font for the first item to a smaller size Arial font.
richTextBox1->SelectionFont = gcnew System::Drawing::Font( "Arial",12 );
// Specify that the following items are to be added to a bulleted list.
richTextBox1->SelectionBullet = true;
// Set the color of the item text.
richTextBox1->SelectionColor = Color::Red;
// Assign the text to the bulleted item.
richTextBox1->SelectedText = "Apples \n";
// Apply same font since font settings do not carry to next line.
richTextBox1->SelectionFont = gcnew System::Drawing::Font( "Arial",12 );
richTextBox1->SelectionColor = Color::Orange;
richTextBox1->SelectedText = "Oranges \n";
richTextBox1->SelectionFont = gcnew System::Drawing::Font( "Arial",12 );
richTextBox1->SelectionColor = Color::Purple;
richTextBox1->SelectedText = "Grapes \n";
// End the bulleted list.
richTextBox1->SelectionBullet = false;
// Specify the font size and string for text displayed below bulleted list.
richTextBox1->SelectionFont = gcnew System::Drawing::Font( "Arial",16 );
richTextBox1->SelectedText = "Bulleted Text Complete!";
}
private void WriteTextToRichTextBox()
{
// Clear all text from the RichTextBox;
richTextBox1.Clear();
// Set the font for the opening text to a larger Arial font;
richTextBox1.SelectionFont = new Font("Arial", 16);
// Assign the introduction text to the RichTextBox control.
richTextBox1.SelectedText = "The following is a list of bulleted items:" + "\n";
// Set the Font for the first item to a smaller size Arial font.
richTextBox1.SelectionFont = new Font("Arial", 12);
// Specify that the following items are to be added to a bulleted list.
richTextBox1.SelectionBullet = true;
// Set the color of the item text.
richTextBox1.SelectionColor = Color.Red;
// Assign the text to the bulleted item.
richTextBox1.SelectedText = "Apples" + "\n";
// Apply same font since font settings do not carry to next line.
richTextBox1.SelectionFont = new Font("Arial", 12);
richTextBox1.SelectionColor = Color.Orange;
richTextBox1.SelectedText = "Oranges" + "\n";
richTextBox1.SelectionFont = new Font("Arial", 12);
richTextBox1.SelectionColor = Color.Purple;
richTextBox1.SelectedText = "Grapes" + "\n";
// End the bulleted list.
richTextBox1.SelectionBullet = false;
// Specify the font size and string for text displayed below bulleted list.
richTextBox1.SelectionFont = new Font("Arial", 16);
richTextBox1.SelectedText = "Bulleted Text Complete!";
}
Private Sub WriteTextToRichTextBox()
' Clear all text from the RichTextBox;
richTextBox1.Clear()
' Set the font for the opening text to a larger Arial font;
richTextBox1.SelectionFont = New Font("Arial", 16)
' Assign the introduction text to the RichTextBox control.
RichTextBox1.SelectedText = "The following is a list of bulleted items:" + ControlChars.Cr
' Set the Font for the first item to a smaller size Arial font.
richTextBox1.SelectionFont = New Font("Arial", 12)
' Specify that the following items are to be added to a bulleted list.
richTextBox1.SelectionBullet = True
' Set the color of the item text.
richTextBox1.SelectionColor = Color.Red
' Assign the text to the bulleted item.
richTextBox1.SelectedText = "Apples" + ControlChars.Cr
' Apply same font since font settings do not carry to next line.
richTextBox1.SelectionFont = New Font("Arial", 12)
richTextBox1.SelectionColor = Color.Orange
richTextBox1.SelectedText = "Oranges" + ControlChars.Cr
richTextBox1.SelectionFont = New Font("Arial", 12)
richTextBox1.SelectionColor = Color.Purple
richTextBox1.SelectedText = "Grapes" + ControlChars.Cr
' End the bulleted list.
richTextBox1.SelectionBullet = False
' Specify the font size and string for text displayed below bulleted list.
richTextBox1.SelectionFont = New Font("Arial", 16)
richTextBox1.SelectedText = "Bulleted Text Complete!"
End Sub