PictureBox クラス
アセンブリ: 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

通常、PictureBox は、ビットマップ、メタファイル、アイコン、JPEG、GIF、または PNG ファイルをグラフィックを表示するために使用します。
デザイン時または実行時に、Image プロパティに、表示する Image を設定します。ImageLocation プロパティを設定してイメージを指定し、イメージを同期的に読み込む場合は Load メソッドを使用し、非同期的に読み込む場合は LoadAsync メソッドを使用します。SizeMode プロパティは PictureBoxSizeMode 列挙体に含まれる値に設定され、表示領域におけるイメージのクリッピングと位置指定を制御します。ClientSize プロパティを使用すると、表示領域のサイズを実行時に変更できます。
既定では、PictureBox コントロールには境界線が表示されません。ピクチャ ボックスにイメージが含まれていない場合でも、そのピクチャ ボックスをフォーム上の他の領域から区別するには、BorderStyle プロパティを使用して、標準の境界線または 3D 境界線を表示できます。PictureBox は選択可能なコントロールではないため、入力フォーカスを受け取ることもできません。

イメージを設定し、ピクチャ ボックスの表示領域のサイズを変更するコード例を次に示します。この例は、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.MarshalByRefObject
System.ComponentModel.Component
System.Windows.Forms.Control
System.Windows.Forms.PictureBox


Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からPictureBox クラスを検索する場合は、下記のリンクをクリックしてください。

- PictureBox クラスのページへのリンク