次の方法で共有


RichTextBox.AutoWordSelection プロパティ

単語の自動選択を有効にするかどうかを示す値を取得または設定します。

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

構文

'宣言
Public Property AutoWordSelection As Boolean
'使用
Dim instance As RichTextBox
Dim value As Boolean

value = instance.AutoWordSelection

instance.AutoWordSelection = value
public bool AutoWordSelection { get; set; }
public:
property bool AutoWordSelection {
    bool get ();
    void set (bool value);
}
/** @property */
public boolean get_AutoWordSelection ()

/** @property */
public void set_AutoWordSelection (boolean value)
public function get AutoWordSelection () : boolean

public function set AutoWordSelection (value : boolean)

プロパティ値

単語の自動選択が有効な場合は true。それ以外の場合は false。既定値は true です。

解説

このプロパティが true に設定されている場合は、コントロール内のテキストの一部を選択すると、その単語全体が選択されます。

使用例

テキストが拡大表示され、コントロールのテキスト内の単語がダブルクリックされたときに単語が自動的に選択され、コントロールのクライアント領域の右側に余白がある RichTextBox を作成する方法を次のコード例に示します。RichTextBox コントロールの幅が小さい場合にこのコードを使用すると、テキストが見かけ上 1 行に 1 文字だけ表示される RichTextBox が作成されます。この垂直表示位置の場合、単語の任意の部分をクリックすると、テキストが縦書きで表示されていることにかかわらず、単語のすべての文字が選択されます。この例では、richTextBox1 という名前の RichTextBox コントロールがフォームに配置されている必要があります。

Private Sub ZoomMyRichTextBox()
    ' Enable users to select entire word when double clicked.
    richTextBox1.AutoWordSelection = True
    ' Clear contents of control.
    richTextBox1.Clear()
    ' Set the right margin to restrict horizontal text.
    richTextBox1.RightMargin = 2
    ' Set the text for the control.
    richTextBox1.SelectedText = "Alpha Bravo Charlie Delta Echo Foxtrot"
    ' Zoom by 2 points.
    richTextBox1.ZoomFactor = 2.0F
End Sub
private void ZoomMyRichTextBox()
{
    // Enable users to select entire word when double clicked.
    richTextBox1.AutoWordSelection = true;
    // Clear contents of control.
    richTextBox1.Clear();
    // Set the right margin to restrict horizontal text.
    richTextBox1.RightMargin = 2;
    // Set the text for the control.
    richTextBox1.SelectedText = "Alpha Bravo Charlie Delta Echo Foxtrot";
    // Zoom by 2 points.
    richTextBox1.ZoomFactor = 2.0f;
}
private:
   void ZoomMyRichTextBox()
   {
      // Enable users to select entire word when double clicked.
      richTextBox1->AutoWordSelection = true;

      // Clear contents of control.
      richTextBox1->Clear();

      // Set the right margin to restrict horizontal text.
      richTextBox1->RightMargin = 2;

      // Set the text for the control.
      richTextBox1->SelectedText = "Alpha Bravo Charlie Delta Echo Foxtrot";

      // Zoom by 2 points.
      richTextBox1->ZoomFactor = 2.0f;
   }
private void ZoomMyRichTextBox()
{
    // Enable users to select entire word when double clicked.
    richTextBox1.set_AutoWordSelection(true);
    // Clear contents of control.
    richTextBox1.Clear();
    // Set the right margin to restrict horizontal text.
    richTextBox1.set_RightMargin(2);
    // Set the text for the control.
    richTextBox1.set_SelectedText("Alpha Bravo Charlie Delta Echo Foxtrot");
    // Zoom by 2 points.
    richTextBox1.set_ZoomFactor(2);
} //ZoomMyRichTextBox

プラットフォーム

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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。

バージョン情報

.NET Framework

サポート対象 : 2.0、1.1、1.0

参照

関連項目

RichTextBox クラス
RichTextBox メンバ
System.Windows.Forms 名前空間