DataGridViewImageColumn.ImageLayout プロパティ

定義

この列のセルのイメージのレイアウトを取得または設定します。

public:
 property System::Windows::Forms::DataGridViewImageCellLayout ImageLayout { System::Windows::Forms::DataGridViewImageCellLayout get(); void set(System::Windows::Forms::DataGridViewImageCellLayout value); };
public System.Windows.Forms.DataGridViewImageCellLayout ImageLayout { get; set; }
member this.ImageLayout : System.Windows.Forms.DataGridViewImageCellLayout with get, set
Public Property ImageLayout As DataGridViewImageCellLayout

プロパティ値

セルのレイアウトを指定する DataGridViewImageCellLayout。 既定値は、Normal です。

例外

CellTemplate プロパティの値が null です。

次のコード例では、セルに合わせて画像を拡大または縮小する方法を示します。 この例は、「How to: Work with Image Columns in the Windows フォーム DataGridView Control」で使用できるより大きな例の一部です。

void Stretch( Object^ sender, EventArgs^ e )
{
   System::Collections::IEnumerator^ myEnum = dataGridView1->Columns->GetEnumerator();
   while ( myEnum->MoveNext() )
   {
      DataGridViewImageColumn^ column = safe_cast<DataGridViewImageColumn^>(myEnum->Current);
      column->ImageLayout = DataGridViewImageCellLayout::Stretch;
      column->Description = L"Stretched";
   }
}

void ZoomToImage( Object^ sender, EventArgs^ e )
{
   System::Collections::IEnumerator^ myEnum1 = dataGridView1->Columns->GetEnumerator();
   while ( myEnum1->MoveNext() )
   {
      DataGridViewImageColumn^ column = safe_cast<DataGridViewImageColumn^>(myEnum1->Current);
      column->ImageLayout = DataGridViewImageCellLayout::Zoom;
      column->Description = L"Zoomed";
   }
}

void NormalImage( Object^ sender, EventArgs^ e )
{
   System::Collections::IEnumerator^ myEnum2 = dataGridView1->Columns->GetEnumerator();
   while ( myEnum2->MoveNext() )
   {
      DataGridViewImageColumn^ column = safe_cast<DataGridViewImageColumn^>(myEnum2->Current);
      column->ImageLayout = DataGridViewImageCellLayout::Normal;
      column->Description = L"Normal";
   }
}
private void Stretch(object sender, EventArgs e)
{
    foreach (DataGridViewImageColumn column in
        dataGridView1.Columns)
    {
        column.ImageLayout = DataGridViewImageCellLayout.Stretch;
        column.Description = "Stretched";
    }
}

private void ZoomToImage(object sender, EventArgs e)
{

    foreach (DataGridViewImageColumn column in
        dataGridView1.Columns)
    {
        column.ImageLayout = DataGridViewImageCellLayout.Zoom;
        column.Description = "Zoomed";
    }
}

private void NormalImage(object sender, EventArgs e)
{

    foreach (DataGridViewImageColumn column in
        dataGridView1.Columns)
    {
        column.ImageLayout = DataGridViewImageCellLayout.Normal;
        column.Description = "Normal";
    }
}
Private Sub Stretch(ByVal sender As Object, _
    ByVal e As EventArgs) Handles Button3.Click

    For Each column As DataGridViewImageColumn _
        In dataGridView1.Columns
        column.ImageLayout = DataGridViewImageCellLayout.Stretch
        column.Description = "Stretched image layout"
    Next
End Sub

Private Sub ZoomToImage(ByVal sender As Object, _
    ByVal e As EventArgs) Handles Button4.Click

    For Each column As DataGridViewImageColumn _
        In dataGridView1.Columns
        column.ImageLayout = DataGridViewImageCellLayout.Zoom
        column.Description = "Zoomed image layout"
    Next
End Sub

Private Sub NormalImage(ByVal sender As Object, _
    ByVal e As EventArgs) Handles Button5.Click

    For Each column As DataGridViewImageColumn _
        In dataGridView1.Columns
        column.ImageLayout = DataGridViewImageCellLayout.Normal
        column.Description = "Normal image layout"
    Next
End Sub

注釈

このプロパティを取得または設定すると、 プロパティによって返されるオブジェクトのプロパティをCellTemplate取得または設定ImageLayoutします。 このプロパティを設定すると、 ImageLayout 列内のすべてのセルのプロパティも設定され、列の表示が更新されます。 個々のセルの指定した値をオーバーライドするには、列の値を設定した後でセル値を設定します。

適用対象

こちらもご覧ください