RadControls for WinForms

GridViewImageColumn displays read-only images for database columns of image data (OLE container or BLOB). 

Note

RadGridView tries to convert data columns that contain unspecified binary data to an image.

Note

Some databases such as Access use OLE image container. RadGridView automatically recognizes that and skips the added header.

Supported image formats are those supported by the Image class of .net framework.

 

gridview-columns-gridviewimagecolumn 001

Copy[C#] Adding GridViewImageColumn
GridViewImageColumn imageColumn = new GridViewImageColumn();
imageColumn.Name = "ImageColumn";
imageColumn.FieldName = "Photo";
imageColumn.HeaderText = "Picture";
imageColumn.ImageLayout = ImageLayout.Zoom;           
//////
radGridView1.MasterTemplate.Columns.Insert(4, imageColumn);
Copy[VB.NET] Adding GridViewImageColumn
Dim imageColumn As New GridViewImageColumn
imageColumn.Name = "ImageColumn"
imageColumn.FieldName = "Photo"
imageColumn.HeaderText = "Picture"
imageColumn.ImageLayout = ImageLayout.Zoom
RadGridView1.MasterTemplate.Columns.Add(imageColumn)

Image Layout

GridViewImageColumn also implements resizing functionality where sizing is controlled by the ImageLayout property. ImageLayout can be set to one of the following: None, Tile, Center, Stretch and Zoom:

  • None - Image is positioned at the upper left corner of the cell. This value can be used in a combination with the value of the ImageAlignment property to specify the position of an image in a cell:

    gridview-columns-gridviewimagecolumn 002

    Copy[C#]
    imageColumn.ImageLayout = ImageLayout.None;
    imageColumn.ImageAlignment = ContentAlignment.BottomRight;
    Copy[VB.NET]
    imageColumn.ImageLayout = ImageLayout.None
    imageColumn.ImageAlignment = ContentAlignment.BottomRight
  • Tile - Image is repeated:

    gridview-columns-gridviewimagecolumn 003

    Copy[C#]
    imageColumn.ImageLayout = ImageLayout.Tile;
    Copy[VB.NET]
    imageColumn.ImageLayout = ImageLayout.Tile
  • Center - Image is positioned at the cell center regardless of the ImageAlignment value:

    gridview-columns-gridviewimagecolumn 004

    Copy[C#]
    imageColumn.ImageLayout = ImageLayout.Center;
    Copy[VB.NET]
    imageColumn.ImageLayout = ImageLayout.Center
  • Stretch - Image is stretched in the cell:

    gridview-columns-gridviewimagecolumn 005

    Copy[C#]
    imageColumn.ImageLayout = ImageLayout.Stretch;
    Copy[VB.NET]
    imageColumn.ImageLayout = ImageLayout.Stretch
  • Zoom - Image is zoomed but the aspect ratio is preserved:

    gridview-columns-gridviewimagecolumn 006

    Copy[C#]
    imageColumn.ImageLayout = ImageLayout.Zoom;
    Copy[VB.NET]
    imageColumn.ImageLayout = ImageLayout.Zoom