Home Forums WinForms controls Xceed Grid for WinForms How to programmatically format a column

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #17662 |

    Assuming the grid is bound to a database and, of course, BEFORE the connection is opened, how to format a column, For instance phone numbers are stored as digits only and I want to display with a mask. I don’t want the grid to compute and transform each cell after the display, I want the display to take into account the formatting.

    Imported from legacy forums. Posted by Frederic (had 943 views)

    Xceed Support
    Member
    Post count: 5658

    Hi Frederic, 

    You could use the GridMaskTextBox to provide amask. You can do something as follows : 

    Xceed.Grid.Editors.GridMaskedTextBox maskEditor = new Xceed.Grid.Editors.GridMaskedTextBox();
    Xceed.Grid.Editors.GridMaskedTextBox maskViewer = new Xceed.Grid.Editors.GridMaskedTextBox();

    gridControl1.Columns[ 0 ].CellEditor = maskEditor;
    gridControl1.Columns[ 0 ].CellViewer = maskViewer;

    maskEditor.Mask = “###-###-###”;

    maskViewer.Mask = “###-###-###”; 

    Imported from legacy forums. Posted by Michel [Xceed] (had 233 views)

    User (Old forums)
    Member
    Post count: 23064

    I also found the following way:

    gridControl1.Columns[<column name>].FormatSpecifier = “###-###-###”;

    Imported from legacy forums. Posted by Frederic (had 1100 views)

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.