Graphics.DpiY 属性

定义

获取此 Graphics 的垂直分辨率。

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

属性值

Graphics 支持的垂直分辨率的值(以每英寸点数为单位)。

示例

以下方法演示如何使用 DpiXDpiY 属性。 此示例旨在与 Windows 窗体一起使用。 若要运行此示例,请将其粘贴到包含 ListBox 命名 listBox1 的窗体中,然后从窗体的构造函数调用此方法。

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

注解

有关创建高分辨率应用程序的详细信息,请参阅

高 DPI

适用于

另请参阅