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.
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:
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:
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:
Copy[C#]
imageColumn.ImageLayout = ImageLayout.Center;
Copy[VB.NET]
imageColumn.ImageLayout = ImageLayout.Center
- Stretch - Image is stretched in the cell:
Copy[C#]
imageColumn.ImageLayout = ImageLayout.Stretch;
Copy[VB.NET]
imageColumn.ImageLayout = ImageLayout.Stretch
- Zoom - Image is zoomed but the aspect ratio is preserved:
Copy[C#]
imageColumn.ImageLayout = ImageLayout.Zoom;
Copy[VB.NET]
imageColumn.ImageLayout = ImageLayout.Zoom