RichTextBox.SelectedText プロパティ
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)

Dim instance As RichTextBox Dim value As String value = instance.SelectedText instance.SelectedText = value
public: virtual property String^ SelectedText { String^ get () override; void set (String^ value) override; }
/** @property */ public String get_SelectedText () /** @property */ public void set_SelectedText (String value)
public override function get SelectedText () : String public override function set SelectedText (value : String)
コントロールで選択されているテキストを表す文字列。

SelectionFont、SelectedText、および SelectionColor の各プロパティと共に SelectionBullet プロパティを使用して、RichTextBox コントロール内に箇条書きリストを作成する方法を次のコード例に示します。この例では、richTextBox1 という名前の RichTextBox コントロールがフォーム上で作成されている必要があります。
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
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: 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.set_SelectionFont(new Font("Arial", 16)); // Assign the introduction text to the RichTextBox control. richTextBox1.set_SelectedText("The following is a list of bulleted items:" + "\n"); // Set the Font for the first item to a smaller size Arial font. richTextBox1.set_SelectionFont(new Font("Arial", 12)); // Specify that the following items are to be added to a bulleted list. richTextBox1.set_SelectionBullet(true); // Set the color of the item text. richTextBox1.set_SelectionColor(Color.get_Red()); // Assign the text to the bulleted item. richTextBox1.set_SelectedText("Apples" + "\n"); // Apply same font since font settings do not carry to next line. richTextBox1.set_SelectionFont(new Font("Arial", 12)); richTextBox1.set_SelectionColor(Color.get_Orange()); richTextBox1.set_SelectedText("Oranges" + "\n"); richTextBox1.set_SelectionFont(new Font("Arial", 12)); richTextBox1.set_SelectionColor(Color.get_Purple()); richTextBox1.set_SelectedText("Grapes" + "\n"); // End the bulleted list. richTextBox1.set_SelectionBullet(false); // Specify the font size and string for text displayed below bulleted list. richTextBox1.set_SelectionFont(new Font("Arial", 16)); richTextBox1.set_SelectedText("Bulleted Text Complete!"); } //WriteTextToRichTextBox

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からRichTextBox.SelectedText プロパティを検索する場合は、下記のリンクをクリックしてください。

- RichTextBox.SelectedText プロパティのページへのリンク