Xceed Grid for WinForms v4.3 Documentation
ImageViewer

Welcome to Xceed Grid for WinForms v4.3 > Basic Concepts > CellEditorManagers and CellViewerManagers > How to use cell viewers > ImageViewer

The ImageViewer can be used to view the content of cells which have an Image datatype.

Using the ImageViewer

By default, the ImageViewer will be created as the CellViewerManager for all columns in the grid which have a boolean datatype. In some cases, the underlying data source will expose images as byte arrays. In these cases, an ImageViewer can be used to display the image, however the CellViewerManager property of the corresponding column will need to be set. 

The image displayed by the ImageViewer can be retrieved using the GetImage method. By default, the ImageArea property of the ImageViewer is set to ImageArea.AllContent indicating that no text is displayed and that the image occupies the entire space. 

If a CellViewerManager other than the ImageViewer is required by default for columns which have an Image datatype, or if byte[] are to be associated with the ImageViewer, the GridControl's CellViewerManagerMapping property can be modified. For example:

VB.NET Copy Code
GridControl1.CellViewerManagerMapping( GetType( byte() ) ) = New ImageViewer()
C# Copy Code
gridControl1.CellViewerManagerMapping[ typeof( byte[] ) ] = new ImageViewer();

If a different CellViewerManager is required for only one column or cell, the CellViewerManager property of the specific column or cell can be set rather than changing the default CellViewerManager that is created for all boolean columns via the CellViewerManagerMapping property.

VB.NET Copy Code
GridControl1.Columns( "Photo" ).CellViewerManager = New ImageViewer()
C# Copy Code
gridControl1.Columns[ "Photo" ].CellViewerManager = new ImageViewer();