Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

DataGridViewImageColumn.Image Property

Gets or sets the image displayed in the cells of this column when the cell's Value property is not set and the cell's ValueIsIcon property is set to false.

Namespace:  System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

public Image Image { get; set; }

Property Value

Type: System.Drawing.Image
The Image to display. The default is null.

The Image property specifies an image that is displayed in cells with no values when the column is not data-bound and the cell's ValueIsIcon property is set to false. For a data-bound column whose cells do not have an associated image, a standard error graphic is displayed.

If you want to display an Icon instead of an Image, set the Icon property instead and set the ValuesAreIcons property to true. This ensures that the alpha channel of the Icon is painted correctly. You can also set the ValueIsIcon property of individual cells to indicate whether the cell displays the Image or the Icon property value when there is no cell value.

The following code example demonstrates how to set the default image. This example is part of a larger example available in How to: Work with Image Columns in the Windows Forms DataGridView Control.

private void CreateColumns()
    DataGridViewImageColumn imageColumn;
    int columnCount = 0;
        Bitmap unMarked = blank;
        imageColumn = new DataGridViewImageColumn();

        //Add twice the padding for the left and  
        //right sides of the cell.
        imageColumn.Width = x.Width + 2 * bitmapPadding + 1;

        imageColumn.Image = unMarked;
        columnCount = columnCount + 1;
    while (columnCount < 3);

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
© 2015 Microsoft