Edit

Share via


DataGridViewImageCellLayout Enum

Definition

Specifies the layout for an image contained in a DataGridViewCell.

C#
public enum DataGridViewImageCellLayout
Inheritance
DataGridViewImageCellLayout

Fields

Name Value Description
NotSet 0

The layout specification has not been set.

Normal 1

The graphic is displayed centered using its native resolution.

Stretch 2

The graphic is stretched by the percentages required to fit the width and height of the containing cell.

Zoom 3

The graphic is uniformly enlarged until it fills the width or height of the containing cell.

Examples

The following code example illustrates the use of this type. This example is part of a larger example available in How to: Work with Image Columns in the Windows Forms DataGridView Control.

C#
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";
    }
}

Applies to

Product Versions
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

See also