Xceed Grid for WinForms v4.3 Documentation
DateViewer

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

The DateViewer can be used to view the content of cells which have a DateTime datatype. 

Using the DateViewer

By default, the DateViewer will be created as the CellViewerManager for all columns in the grid which have a DateTime datatype. 

The date displayed by the DateViewer can be retrieved via the GetText method. The date will be returned as a string and formatted according to the cell's FormatProvider and FormatSpecifier properties. The date can also be retrieved as a DateTime value using the GetDate method. 

If a CellViewerManager other than the DateViewer is desired by default for columns which have a DateTime datatype, the GridControl's CellViewerManagerMapping property can be modified. For example:

VB.NET Copy Code
GridControl1.CellViewerManagerMapping( GetType( DateTime ) ) = New CustomDateViewer()
C# Copy Code
GridControl1.CellViewerManagerMapping( GetType( DateTime ) ) = New CustomDateViewer()

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 DateTime columns via the CellViewerManagerMapping property.

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

Underlying control

The underlying control wrapped by the DateViewer is the WinDatePicker control and is accessible through the Control property. All settings relating to the underlying control must be accessed via the Control property. 

More information regarding the WinDatePicker control can be found in the WinDatePicker control topic.