Graphics.DrawIconとは? わかりやすく解説

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

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

名前空間: System.Drawing
アセンブリ: System.Drawing (system.drawing.dll 内)
構文構文

Public Sub DrawIcon ( _
    icon As Icon, _
    x As Integer, _
    y As Integer _
)
Dim instance As Graphics
Dim icon As Icon
Dim x As Integer
Dim y As Integer

instance.DrawIcon(icon, x, y)
public void DrawIcon (
    Icon icon,
    int x,
    int y
)
public:
void DrawIcon (
    Icon^ icon, 
    int x, 
    int y
)
public void DrawIcon (
    Icon icon, 
    int x, 
    int y
)
public function DrawIcon (
    icon : Icon, 
    x : int, 
    y : int
)

パラメータ

icon

描画する Icon

x

描画イメージ左上隅の x 座標

y

描画イメージ左上隅の y 座標

例外例外
例外種類条件

ArgumentNullException

iconnull 参照 (Visual Basic では Nothing) です。

使用例使用例

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

描画したアイコンスケーリングされていません。

Public Sub DrawIconInt(ByVal
 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
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);
}
public:
   void DrawIconInt( PaintEventArgs^ e )
   {

      // Create icon.
      System::Drawing::Icon^ newIcon = gcnew System::Drawing::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 );
   }
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

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

Rectangle 構造体指定され領域内の指定した Icon によって表されるイメージ描画ます。

名前空間: System.Drawing
アセンブリ: System.Drawing (system.drawing.dll 内)
構文構文

Public Sub DrawIcon ( _
    icon As Icon, _
    targetRect As Rectangle _
)
Dim instance As Graphics
Dim icon As Icon
Dim targetRect As Rectangle

instance.DrawIcon(icon, targetRect)
public void DrawIcon (
    Icon icon,
    Rectangle targetRect
)
public:
void DrawIcon (
    Icon^ icon, 
    Rectangle targetRect
)
public void DrawIcon (
    Icon icon, 
    Rectangle targetRect
)
public function DrawIcon (
    icon : Icon, 
    targetRect : Rectangle
)

パラメータ

icon

描画する Icon

targetRect

ディスプレイ表面における生成イメージの場所とサイズ指定する Rectangle 構造体icon パラメータ含まれるイメージは、この四角形領域大きさ合わせてスケーリングされます

例外例外
例外種類条件

ArgumentNullException

iconnull 参照 (Visual Basic では Nothing) です。

使用例使用例

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

四角形位置によって画面上のアイコンの場所が決まり四角形サイズによって描画したアイコンスケーリング決まります

Public Sub DrawIconRectangle(ByVal
 e As PaintEventArgs)

    ' Create icon.
    Dim newIcon As New Icon("SampIcon.ico")

    ' Create rectangle for icon.
    Dim rect As New Rectangle(100,
 100, 200, 200)

    ' Draw icon to screen.
    e.Graphics.DrawIcon(newIcon, rect)
End Sub
public void DrawIconRectangle(PaintEventArgs
 e)
{        
    // Create icon.
    Icon newIcon = new Icon("SampIcon.ico");
             
    // Create rectangle for icon.
    Rectangle rect = new Rectangle(100, 100, 200, 200);
             
    // Draw icon to screen.
    e.Graphics.DrawIcon(newIcon, rect);
}
public:
   void DrawIconRectangle( PaintEventArgs^ e )
   {
      // Create icon.
      System::Drawing::Icon^ newIcon = gcnew System::Drawing::Icon( "SampIcon.ico"
 );

      // Create rectangle for icon.
      Rectangle rect = Rectangle(100,100,200,200);

      // Draw icon to screen.
      e->Graphics->DrawIcon( newIcon, rect );
   }
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

Graphics.DrawIcon メソッド




英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「Graphics.DrawIcon」の関連用語

Graphics.DrawIconのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



Graphics.DrawIconのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS