Graphics.DpiY 属性

定义

获取此 Graphics 的垂直分辨率。Gets the vertical resolution of this Graphics.

public:
 property float DpiY { float get(); };
public float DpiY { get; }
member this.DpiY : single
Public ReadOnly Property DpiY As Single

属性值

Single

Graphics 支持的垂直分辨率的值(以每英寸点数为单位)。The value, in dots per inch, for the vertical resolution supported by this Graphics.

示例

下面的方法演示如何使用 DpiXDpiY 属性。The following method shows the use of the DpiX and DpiY properties. 此示例旨在与 Windows 窗体一起使用。This example is designed for use with a Windows Form. 若要运行此示例,请将其粘贴到包含名为 listBox1 的窗体中 ListBox ,并从窗体的构造函数调用此方法。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.Items.Add("ListBox horizontal resolution: " 
        + boxGraphics.DpiX);
    listBox1.Items.Add("ListBox vertical resolution: " 
        + boxGraphics.DpiY);

    boxGraphics.Dispose();
}
Private Sub PopulateListBoxWithGraphicsResolution()
    Dim boxGraphics As Graphics = listBox1.CreateGraphics()
    Dim formGraphics As Graphics = Me.CreateGraphics()

    listBox1.Items.Add("ListBox horizontal resolution: " _
        & boxGraphics.DpiX)
    listBox1.Items.Add("ListBox vertical resolution: " _
        & boxGraphics.DpiY)

    boxGraphics.Dispose()
End Sub

注解

有关创建高分辨率应用程序的详细信息,请参阅。For more information about creating high-resolution applications, see

高 DPIHigh DPI.

适用于

另请参阅