RichTextBox.ZoomFactor 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取或设置当前缩放级别的 RichTextBox。
public:
property float ZoomFactor { float get(); void set(float value); };
public float ZoomFactor { get; set; }
member this.ZoomFactor : single with get, set
Public Property ZoomFactor As Single
属性值
控件内容缩放的因子。
例外
指定的缩放因子未在允许的范围内。
示例
下面的代码示例演示如何创建 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
注解
此属性的值可以介于 1/64(0.015625)和 64.0 之间,不包括。 值为 1.0 表示不对控件应用缩放。 当文档包含 TrueType 字体时,缩放功能的性能最佳。 当控件文档中使用非 TrueType 的字体时,该 ZoomFactor 属性将使用最接近的整数值。 可以使用此属性使控件的用户 RichTextBox 能够放大文档部分,这些部分太小,无法查看或压缩视图,以使更多文档能够在屏幕上查看。