次の方法で共有


Graphics.DrawIcon メソッド (Icon, Int32, Int32)

指定した Icon オブジェクトによって表されるイメージを指定した座標に描画します。

Overloads Public Sub DrawIcon( _
   ByVal icon As Icon, _   ByVal x As Integer, _   ByVal y As Integer _)
[C#]
public void DrawIcon(Iconicon,intx,inty);
[C++]
public: void DrawIcon(Icon* icon,intx,inty);
[JScript]
public function DrawIcon(
   icon : Icon,x : int,y : int);

パラメータ

  • icon
    描画する Icon オブジェクト。
  • x
    描画イメージの左上隅の x 座標。
  • y
    描画イメージの左上隅の y 座標。

戻り値

このメソッドは値を返しません。

使用例

[Visual Basic, C#] 次の例は、Windows フォームでの使用を意図してデザインされており、 Paint イベント ハンドラのパラメータである PaintEventArgs e が必要です。このコードは次のアクションを実行します。

  • この例が保存されているフォルダにある標準の Windows アイコン ファイル SampIcon.ico からアイコンを作成します。
  • アイコンを描画する左上隅の座標を作成します。
  • 画面にアイコンを描画します。

[Visual Basic, C#] 描画したアイコンはスケーリングされていません。

 
Public Sub DrawIconInt(e As PaintEventArgs)
' Create icon.
Dim newIcon As New Icon("SampIcon.ico")
' Create coordinates for upper-left corner of icon.
Dim x As Integer = 100
Dim y As Integer = 100
' Draw icon to screen.
e.Graphics.DrawIcon(newIcon, x, y)
End Sub
        
[C#] 
public void DrawIconInt(PaintEventArgs e)
{
// Create icon.
Icon newIcon = new Icon("SampIcon.ico");
// Create coordinates for upper-left corner of icon.
int x = 100;
int y = 100;
// Draw icon to screen.
e.Graphics.DrawIcon(newIcon, x, y);
}
        

[C++, JScript] C++ および JScript のサンプルはありません。Visual Basic および C# のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ, .NET Compact Framework - Windows CE .NET

参照

Graphics クラス | Graphics メンバ | System.Drawing 名前空間 | Graphics.DrawIcon オーバーロードの一覧