Xceed Grid for WinForms v4.3 Documentation
CellEditorManagers and CellViewerManagers

Welcome to Xceed Grid for WinForms v4.3 > Basic Concepts > CellEditorManagers and CellViewerManagers

The content of any cell in a grid can be displayed or edited using a CellViewerManager or CellEditorManager respectively. 

Each cell or column can have a CellViewerManager or CellEditorManager assigned to its CellViewerManager and/or CellEditorManager properties. If a CellViewerManager is assigned to the CellViewerManager property of a column, it will be used to view the content of each cell in the column unless a cell's CellViewerManager property has been explicitly set, in which case the cell's CellViewerManager will be used to display the content of that specific cell. 

In some cases, a default CellViewerManager or CellEditorManager will be created according to the datatype of the column. For example, if a column has an Image datatype, an ImageViewer will be associated with the column and will be used to view the content of each cell in the column. 

The following table provides a list of the default CellViewerManagers and CellEditorManagers which are created by default for specific datatypes. 

Datatype Default CellViewerManager Default CellEditorManager
Boolean CheckBoxViewer CheckBoxEditor
Image ImageViewer (none)
String (none) TextEditor
DateTime DateViewer DateEditor
Numeric NumericViewer NumericEditor
byte[] ImageViewer (none)
Other (none) (none)
The default CellViewerManagers and CellEditorManagers that are created can be removed or replaced with a predefined CellViewerManager or CellEditorManager or with a custom CellViewerManager or CellViewerEditor

The GridControl class exposes the CellViewerManagerMapping and CellEditorManagerMapping properties which contain a list of the CellViewerManagers and CellEditorManagers which are created by default for specified datatypes. Values contained in these collections can be modified, added, or removed to change the CellViewerManager or CellEditorManager which is created by default for all columns of the specified datatype. If null (Nothing in Visual Basic) is assigned to the CellViewerManagerMapping or CellEditorManagerMapping properties, the default editors will be used.

Using the CellViewerManagers and CellEditorManagers

The default CellViewerManagers and CellEditorsManagers  that are created can be removed or replaced with one of the above mentioned predefined CellViewerManagers or CellEditorsManagers   or with a custom CellViewerManager/CellEditorsManager by setting the CellViewerManager or CellEditorsManager properties of either or a column or a specific cell. 

For example, in the code snippets below, the CellViewerManager and CellEditorsManager properties of the "Phone" column are set to a masked TextViewer and masked TextEditor so that the values that are displayed and edited in the column's cells have the correct phone format.

VB.NET Copy Code
GridControl1.Columns( "Phone" ).CellViewerManager = New TextViewer( "( ### ) ###-####" )
GridControl1.Columns( "Phone" ).CellEditorManager = New TextEditor( "( ### ) ###-####" ) 
C# Copy Code
gridControl1.Columns[ "Phone" ].CellViewerManager = new TextViewer( "( ### ) ###-####" );
gridControl1.Columns[ "Phone" ].CellEditorManager = new TextEditor( "( ### ) ###-####" );

Custom CellViewerManagers and CellViewerEditors

Custom CellViewerManagers can be created by either wrapping a control in a CellViewerManager, by using a CellViewerManager to provide custom painting for a cell's background and/or foreground, or by deriving from the CellViewerManager (TrackBarViewer | BooleanImageTextViewer). 

Custom CellEditorManagers can be created by either wrapping a control in a CellEditorManager or by deriving from the CellEditorManager class.

CellViewerManagers and reporting

When generating a report using the reporting capabilities of Xceed Grid for WinForms, CellViewerManagers will only be reproduced in the report if the GetImage and/or GetText methods return the image or text that is to be displayed (GetImageCore and/or GetTextCore have been overridden). In the case where the GetImageCore and/or GetTextCore methods have not been overridden to return the desired image and/or text, the string representation of the underlying cell's content will be displayed in the report.