Graphics.PageUnit 属性

获取或设置用于此 Graphics 中的页坐标的度量单位。

**命名空间:**System.Drawing
**程序集:**System.Drawing(在 system.drawing.dll 中)

语法

声明
Public Property PageUnit As GraphicsUnit
用法
Dim instance As Graphics
Dim value As GraphicsUnit

value = instance.PageUnit

instance.PageUnit = value
public GraphicsUnit PageUnit { get; set; }
public:
property GraphicsUnit PageUnit {
    GraphicsUnit get ();
    void set (GraphicsUnit value);
}
/** @property */
public GraphicsUnit get_PageUnit ()

/** @property */
public void set_PageUnit (GraphicsUnit value)
public function get PageUnit () : GraphicsUnit

public function set PageUnit (value : GraphicsUnit)

属性值

GraphicsUnit 值之一。

备注

图形单位是用于此 Graphics 中的页坐标的度量单位。

示例

下面的代码示例演示了更改 PageUnit 属性的结果。

此示例是针对使用 Windows 窗体而设计的。将代码粘贴到一个窗体中,然后在处理窗体的 Paint 事件时调用 ChangePageUnit 方法,并传递 e 作为 PaintEventArgs

Private Sub ChangePageUnit(ByVal e As PaintEventArgs)

    ' Create a rectangle.
    Dim rectangle1 As New Rectangle(20, 20, 50, 100)

    ' Draw its outline.
    e.Graphics.DrawRectangle(Pens.SlateBlue, rectangle1)

    ' Change the page scale.  
    e.Graphics.PageUnit = GraphicsUnit.Point

    ' Draw the rectangle again.
    e.Graphics.DrawRectangle(Pens.Tomato, rectangle1)

End Sub
private void ChangePageUnit(PaintEventArgs e)
{

    // Create a rectangle.
    Rectangle rectangle1 = new Rectangle(20, 20, 50, 100);

    // Draw its outline.
    e.Graphics.DrawRectangle(Pens.SlateBlue, rectangle1);

    // Change the page scale.  
    e.Graphics.PageUnit = GraphicsUnit.Point;

    // Draw the rectangle again.
    e.Graphics.DrawRectangle(Pens.Tomato, rectangle1);

}
private:
   void ChangePageUnit( PaintEventArgs^ e )
   {
      // Create a rectangle.
      Rectangle rectangle1 = Rectangle(20,20,50,100);

      // Draw its outline.
      e->Graphics->DrawRectangle( Pens::SlateBlue, rectangle1 );

      // Change the page scale.  
      e->Graphics->PageUnit = GraphicsUnit::Point;

      // Draw the rectangle again.
      e->Graphics->DrawRectangle( Pens::Tomato, rectangle1 );
   }
private void ChangePageUnit(PaintEventArgs e)
{
    // Create a rectangle.
    Rectangle rectangle1 = new Rectangle(20, 20, 50, 100);

    // Draw its outline.
    e.get_Graphics().DrawRectangle(Pens.get_SlateBlue(), rectangle1);

    // Change the page scale.  
    e.get_Graphics().set_PageUnit(GraphicsUnit.Point);

    // Draw the rectangle again.
    e.get_Graphics().DrawRectangle(Pens.get_Tomato(), rectangle1);
} //ChangePageUnit

平台

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

请参见

参考

Graphics 类
Graphics 成员
System.Drawing 命名空间