Editare

Partajați prin


RichTextBox.ZoomFactor Property

Definition

Gets or sets the current zoom level of the 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

Property Value

The factor by which the contents of the control is zoomed.

Exceptions

The specified zoom factor did not fall within the permissible range.

Examples

The following code example demonstrates how to create a RichTextBox that zooms in on text, automatically selects words in the text of the control when a word is double-clicked, and has a margin on the right side of the client area of the control. If the RichTextBox control has a small width, using this code will create a RichTextBox where each character of text is displayed on its own line. While in this vertical display position, clicking on any part of a word will select all characters of the word regardless of the fact that the text is displayed vertically. This example requires that you have a form that contains a RichTextBox control named 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

Remarks

The value of this property can be between 1/64 (0.015625) and 64.0, not inclusive. A value of 1.0 indicates that no zoom is applied to the control. The zoom feature performs optimally when the document contains TrueType fonts. When a font that is not TrueType is used within the document of the control, the ZoomFactor property will use the nearest whole number value. You can use this property to enable the user of the RichTextBox control to zoom into sections of the documentation that are too small to view or to condense the view to enable more of the document to be viewed on screen.

Applies to