Xceed Grid for WinForms v4.3 Documentation
CustomTextBoxArea class C# implementation
Welcome to Xceed Grid for WinForms v4.3 > Advanced Concepts > Editors - Advanced Concepts > Adding mask characters > CustomTextBoxArea class C# implementation

The following code provides the C# implementation of the CustomTextBoxArea class.

C# Copy Code

using System;
using Xceed.Editors; 

namespace Xceed.Editors.Samples
{
  public class CustomTextBoxArea : TextBoxArea
  {
    public CustomTextBoxArea( WinTextBox textBox )
      :base( textBox )
    {
    }

    protected override char[] MaskChars
    {
      get
      {
        char[] chars = new char[ base.MaskChars.Length + 1 ];
        base.MaskChars.CopyTo( chars, 0 );
        chars[ base.MaskChars.Length ] = '$'; 
 
        return chars;
      }
     }

     protected override bool IsCharValid( char maskChar, char charToValidate )
     {
       bool valid = base.IsCharValid( maskChar, charToValidate ); 

       if( !valid )
       {
         if( maskChar == '$' &&
             charToValidate == '+' || charToValidate == '-' ||
             charToValidate == '*' || charToValidate == '/' )
         {
           valid = true;
         }      
       }

       return valid;
     }
   }
}