Gets or sets the unit of measure used for page coordinates in this
Graphics.
Namespace: System.Drawing
Assembly: System.Drawing (in system.drawing.dll)
Visual Basic (Declaration)
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)
Property Value
One of the GraphicsUnit values other than World.
The graphics unit is the unit of measure used for page coordinates in this Graphics.
The following code example demonstrates the effect of changing the PageUnit property.
This example is designed to be used with Windows Forms. Paste the code into a form and call the ChangePageUnit method when handling the form's Paint event, passing e as 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 Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.
.NET Framework
Supported in: 3.0, 2.0, 1.1, 1.0