RichTextBox.SelectedText Özellik
Tanım
Önemli
Bazı bilgiler ürünün ön sürümüyle ilgilidir ve sürüm öncesinde önemli değişiklikler yapılmış olabilir. Burada verilen bilgilerle ilgili olarak Microsoft açık veya zımni hiçbir garanti vermez.
içinde RichTextBoxseçili metni alır veya ayarlar.
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
Özellik Değeri
Denetimde seçili metni temsil eden bir dize.
- Öznitelikler
Örnekler
Aşağıdaki kod örneği, bir denetimde SelectionBullet madde işaretli liste RichTextBox oluşturmak için , SelectedTextve SelectionColor özellikleriyle SelectionFontözelliğinin nasıl kullanılacağını gösterir. Bu örnek, formda adlı richTextBox1
bir RichTextBox denetimin oluşturulmasını gerektirir.
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