RichTextBox.AutoWordSelection 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取或设置一个值,该值指示是否启用自动单词选择。
public:
property bool AutoWordSelection { bool get(); void set(bool value); };
public bool AutoWordSelection { get; set; }
member this.AutoWordSelection : bool with get, set
Public Property AutoWordSelection As Boolean
属性值
true 如果启用了自动单词选择,则为否则,为 false. 默认值为 true。
示例
下面的代码示例演示如何创建 RichTextBox 放大文本的控件,在双击单词时自动选择控件文本中的单词,并在控件工作区右侧有边距。
RichTextBox如果控件的宽度较小,则使用此代码将创建RichTextBox文本的每个字符在其自己的行上显示的位置。 在此垂直显示位置中,单击单词的任何部分将选择单词的所有字符,而不考虑文本垂直显示的事实。 此示例要求你有一个包含名为 <
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 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
注解
如果此属性设置为 true,则选择控件中文本的任何部分将选择整个单词。