Graphics.DpiX Property

Gets the horizontal resolution of this Graphics.

Namespace: System.Drawing
Assembly: System.Drawing (in system.drawing.dll)

public:
property float DpiX {
	float get ();
}
/** @property */
public float get_DpiX ()

public function get DpiX () : float

Not applicable.

Property Value

The value, in dots per inch, for the horizontal resolution supported by this Graphics.

The following method shows the use of the DpiX and DpiY properties. This example is designed for use with a Windows Form. To run this example, paste it into a form that contains a ListBox named listBox1 and call this method from the form's constructor.

private:
   void PopulateListBoxWithGraphicsResolution()
   {
      Graphics^ boxGraphics = listBox1->CreateGraphics();

      // Graphics* formGraphics = this->CreateGraphics();
      listBox1->Items->Add( String::Format( "ListBox horizontal resolution: {0}", boxGraphics->DpiX ) );
      listBox1->Items->Add( String::Format( "ListBox vertical resolution: {0}", boxGraphics->DpiY ) );
      delete boxGraphics;
   }

private void PopulateListBoxWithGraphicsResolution()
{
    Graphics boxGraphics = listBox1.CreateGraphics();
    Graphics formGraphics = this.CreateGraphics();

    listBox1.get_Items().Add(("ListBox horizontal resolution: " 
        + boxGraphics.get_DpiX()));
    listBox1.get_Items().Add(("ListBox vertical resolution: " 
        + boxGraphics.get_DpiY()));
    boxGraphics.Dispose();
} //PopulateListBoxWithGraphicsResolution

Windows 98, Windows Server 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

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

.NET Compact Framework

Supported in: 2.0

Community Additions

ADD
Show: