Xceed Grid for WinForms v4.3 Documentation
How to format data using mask (#) characters

Welcome to Xceed Grid for WinForms v4.3 > Task-Based Help > Appearance > How to format data using mask (#) characters

In order to format data using mask (#) characters for an entire column or a specific cell, you must use the TextViewer and TextEditor. Simply setting the column or cell's FormatSpecifier property will not function. 

You can also change the format of text displayed in a cell (or in an entire column) by creating a class that implements the IFormatProvider interface and assigning your custom class to the FormatProvider and FormatSpecifier properties of the desired cell or column. 

For more information regarding the implementation of the IFormatProvider interface, go to the "Customizing Format Strings" topic of the .NET Framework's documentation.

Demonstration

To use the TextViewer and TextEditor to format data using mask (#) characters, the following code can be used:

VB.NET Copy Code

GridControl1.Columns( "Phone" ).CellEditorManager = New Xceed.Grid.Editors.TextEditor( "( ### ) ###-####" )

GridControl1.Columns( "Phone" ).CellViewerManager = New Xceed.Grid.Viewers.TextViewer( "( ### ) ###-####" )

C# Copy Code

gridControl1.Columns[ "Phone" ].CellEditorManager = new Xceed.Grid.Editors.TextEditor( "( ### ) ###-####" );

gridControl1.Columns[ "Phone" ].CellViewerManager = new Xceed.Grid.Viewers.TextViewer( "( ### ) ###-####" );