Label.Image プロパティ
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
Labelに表示されるイメージを取得または設定します。
public:
property System::Drawing::Image ^ Image { System::Drawing::Image ^ get(); void set(System::Drawing::Image ^ value); };
public System.Drawing.Image Image { get; set; }
public System.Drawing.Image? Image { get; set; }
member this.Image : System.Drawing.Image with get, set
Public Property Image As Image
プロパティ値
Labelに表示されるImage。 既定値は、null です。
例
次のコード例では、Labelを作成し、Labelの背後にImageを表示する方法を示します。 最初に、この例では Label を作成し、次にディスク ファイルに基づいて Image を作成します。 次に、 Size プロパティが初期化され、 Imageが格納されます。 最後に、 Image プロパティが Imageに初期化されます。
public:
void CreateMyLabel()
{
// Create a new label and create a bitmap.
Label^ label1 = gcnew Label;
Image^ image1 = Image::FromFile( "c:\\MyImage.bmp" );
// Set the size of the label to accommodate the bitmap size.
label1->Size = System::Drawing::Size( image1->Width, image1->Height );
// Initialize the label control's Image property.
label1->Image = image1;
// ...Code to add the control to the form...
}
public void CreateMyLabel()
{
// Create a new label and create a bitmap.
Label label1 = new Label();
Image image1 = Image.FromFile("c:\\MyImage.bmp");
// Set the size of the label to accommodate the bitmap size.
label1.Size = new Size(image1.Width, image1.Height);
// Initialize the label control's Image property.
label1.Image = image1;
// ...Code to add the control to the form...
}
Private Sub CreateMyLabel()
' Create a new label and bitmap.
Dim Label1 As New Label()
Dim Image1 As Image
Image1 = Image.FromFile("c:\\MyImage.bmp")
' Set the size of the label to accommodate the bitmap size.
Label1.Size = Image1.Size
' Initialize the label control's Image property.
Label1.Image = Image1
' ...Code to add the control to the form...
End Sub
注釈
Image プロパティは、ImageList プロパティおよびImageIndex プロパティと同時に使用することはできません。 Image プロパティを使用してイメージを表示すると、ImageListプロパティとImageIndexプロパティは自動的に既定の設定に設定されます。