Home Forums WinForms controls Xceed Grid for WinForms Phone mask question Reply To: Phone mask question

User (Old forums)
Member
Post count: 23064

You will need to set a CellViewerManager on each cell, so that you can set each instance as you require. You can use the AddingDataRow event for this.

e.g.:

<code>
private void Form1_Load(object sender, System.EventArgs e)
{
gridControl1.AddingDataRow += new AddingDataRowEventHandler( gridControl1_AddingDataRow );
}

private void gridControl1_AddingDataRow(object sender, AddingDataRowEventArgs e)
{
e.DataRow.Cells[ “HomePhone” ].CellViewerManager = new TextViewer();
}
</code>’

Then in whatever event you use to change the mask, you will be able to do it on that specific instance.
<code>
void CheckBox_ValueChanged( object sender, EventArgs e )
{
DataCell cell = sender as DataCell;
if( ( bool )cell.Value )
{
( ( TextViewer )cell.ParentRow.Cells[ “HomePhone” ].CellViewerManager ).Mask = “### ###-####”;
}
else
{
( ( TextViewer )cell.ParentRow.Cells[ “HomePhone” ].CellViewerManager ).ResetMask();
}
}
</code>

Imported from legacy forums. Posted by André (had 252 views)