共用方式為


Graphics.DpiY 屬性

定義

取得這個 Graphics 的垂直解析度。

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

屬性值

這個 Graphics 所支援的垂直解析度的值,以 DPI 為單位。

範例

下列方法顯示 和 DpiY 屬性的使用DpiX方式。 此範例是設計來搭配 Windows Form 使用。 若要執行此範例,請將它貼到包含 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

適用於

另請參閱