PictureBox クラスとは? わかりやすく解説

PictureBox クラス

イメージ表示するために使用する Windows ピクチャ ボックス コントロール表します

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

<ComVisibleAttribute(True)> _
<ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)> _
Public Class PictureBox
    Inherits Control
    Implements ISupportInitialize
[ComVisibleAttribute(true)] 
[ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)] 
public class PictureBox : Control, ISupportInitialize
[ComVisibleAttribute(true)] 
[ClassInterfaceAttribute(ClassInterfaceType::AutoDispatch)] 
public ref class PictureBox : public
 Control, ISupportInitialize
/** @attribute ComVisibleAttribute(true) */ 
/** @attribute ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) */ 
public class PictureBox extends Control implements
 ISupportInitialize
ComVisibleAttribute(true) 
ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) 
public class PictureBox extends
 Control implements ISupportInitialize
解説解説
使用例使用例

イメージ設定しピクチャ ボックス表示領域サイズ変更するコード例次に示します。この例は、ShowMyImage既存フォーム内から呼び出されSystem.Drawing 名前空間が、そのフォームソース コード追加されていることを前提にしています。

Private MyImage As Bitmap
   
Public Sub ShowMyImage(fileToDisplay As
 String, xSize As Integer,
 _
                       ySize As Integer)
    ' Sets up an image object to be displayed.
    If (MyImage IsNot Nothing) Then
        MyImage.Dispose()
    End If
       
    ' Stretches the image to fit the pictureBox. 
    pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage
    MyImage = New Bitmap(fileToDisplay)
    pictureBox1.ClientSize = New Size(xSize, ySize)
    pictureBox1.Image = CType(MyImage, Image)
End Sub

private Bitmap MyImage ;
public void ShowMyImage(String fileToDisplay,
 int xSize, int ySize)
{
   // Sets up an image object to be displayed.
   if (MyImage != null)
   {
      MyImage.Dispose();
   }

   // Stretches the image to fit the pictureBox.
   pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage ;
   MyImage = new Bitmap(fileToDisplay);
   pictureBox1.ClientSize = new Size(xSize, ySize);
   pictureBox1.Image = (Image) MyImage ;
}

   Bitmap^ MyImage;

public:
   void ShowMyImage( String^ fileToDisplay, int
 xSize, int ySize )
   {
      
      // Sets up an image object to be displayed.
      if ( MyImage != nullptr )
      {
         delete MyImage;
      }

      
      // Stretches the image to fit the pictureBox.
      pictureBox1->SizeMode = PictureBoxSizeMode::StretchImage;
      MyImage = gcnew Bitmap( fileToDisplay );
      pictureBox1->ClientSize = System::Drawing::Size( xSize, ySize );
      pictureBox1->Image = dynamic_cast<Image^>(MyImage);
   }

private Bitmap myImage;
public void ShowMyImage(String fileToDisplay,
 int xSize, int ySize)
{
    // Sets up an image object to be displayed.
    if (myImage != null) {
        myImage.Dispose();
    }

    // Stretches the image to fit the pictureBox.
    pictureBox1.set_SizeMode(PictureBoxSizeMode.StretchImage);
    myImage = new Bitmap(fileToDisplay);
    pictureBox1.set_ClientSize(new Size(xSize, ySize));
    pictureBox1.set_Image(myImage);
} //ShowMyImage
継承階層継承階層
System.Object
   System.MarshalByRefObject
     System.ComponentModel.Component
       System.Windows.Forms.Control
        System.Windows.Forms.PictureBox
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



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

辞書ショートカット

すべての辞書の索引

「PictureBox クラス」の関連用語

PictureBox クラスのお隣キーワード
検索ランキング

   

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



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

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

©2025 GRAS Group, Inc.RSS