RichTextBox.SelectionLength プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > RichTextBox.SelectionLength プロパティの意味・解説 

RichTextBox.SelectionLength プロパティ

コントロール内で選択されている文字の数を取得または設定します

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

Public Overrides Property
 SelectionLength As Integer
Dim instance As RichTextBox
Dim value As Integer

value = instance.SelectionLength

instance.SelectionLength = value
public override int SelectionLength { get;
 set; }
/** @property */
public int get_SelectionLength ()

/** @property */
public void set_SelectionLength (int
 value)
public override function get
 SelectionLength () : int

public override function set
 SelectionLength (value : int)

プロパティ
テキスト ボックス内で選択されている文字の数。

解説解説
使用例使用例

SelectionLength プロパティ使用して、RichTextBox 内でテキスト選択されているかどうか確認する方法次のコード例示します。この例では、richTextBox1 という名前の RichTextBox コントロールフォーム追加されている必要がありますまた、コントロール選択されているテキストrichTextBox1含まれている必要もあります

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 ModifySelectedText()
{
   // Determine if text is selected in the control.
   if (richTextBox1.SelectionLength > 0)
   {
      // Set the color of the selected text in the control.
      richTextBox1.SelectionColor = Color.Red;
      // Set the font of the selected text to bold and underlined.
      richTextBox1.SelectionFont = new Font("Arial",10,FontStyle.Bold
 | FontStyle.Underline);
      // Protect the selected text from modification.
      richTextBox1.SelectionProtected = true;
   }
}
private:
   void ModifySelectedText()
   {
      // Determine if text is selected in the control.
      if ( richTextBox1->SelectionLength > 0 )
      {
         // Set the color of the selected text in the control.
         richTextBox1->SelectionColor = Color::Red;

         // Set the font of the selected text to bold and underlined.
         richTextBox1->SelectionFont = gcnew System::Drawing::Font( "Arial",10,static_cast<FontStyle>(FontStyle::Bold
 | FontStyle::Underline) );

         // Protect the selected text from modification.
         richTextBox1->SelectionProtected = true;
      }
   }
private void ModifySelectedText()
{
    // Determine if text is selected in the control.
    if (richTextBox1.get_SelectionLength() > 0) {
        // Set the color of the selected text in the control.
        richTextBox1.set_SelectionColor(Color.get_Red());
        // Set the font of the selected text to bold and underlined.
        richTextBox1.set_SelectionFont(new Font("Arial",
 10, FontStyle.
            Bold | FontStyle.Underline));
        // Protect the selected text from modification.
        richTextBox1.set_SelectionProtected(true);
    }
} //ModifySelectedText
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
RichTextBox クラス
RichTextBox メンバ
System.Windows.Forms 名前空間
SelectionStart
SelectedText


このページでは「.NET Framework クラス ライブラリ リファレンス」からRichTextBox.SelectionLength プロパティを検索した結果を表示しています。
Weblioに収録されているすべての辞書からRichTextBox.SelectionLength プロパティを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からRichTextBox.SelectionLength プロパティ を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

RichTextBox.SelectionLength プロパティのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



RichTextBox.SelectionLength プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS