RichTextBox.ZoomFactor 屬性

定義

取得或設定 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 其中每一個字元的文字都會顯示在自己的行上。 在這個垂直顯示位置中,按一下單字的任何部分將會選取單字的所有字元,而不論文字垂直顯示的事實為何。 此範例需要您有一個表單,其中包含 RichTextBox 名為 的 richTextBox1 控制項。

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 能夠放大檔太小而無法檢視的檔區段,或壓縮檢視,以在畫面上檢視更多檔。

適用於