Class MaskAttribute
Specifies the input mask for a property, so that it can be edited using MaskEditor in PropertyGrid.
Inheritance
Namespace: Syncfusion.Windows.PropertyGrid
Assembly: Syncfusion.PropertyGrid.Wpf.dll
Syntax
public class MaskAttribute : Attribute
Constructors
MaskAttribute(String)
Initializes a new instance of the MaskAttribute class with input mask.
Declaration
public MaskAttribute(string mask)
Parameters
Type | Name | Description |
---|---|---|
System.String | mask | The input mask for property. |
Examples
// Built-In mask to get valid email id from user.
[MaskAttribute(MaskAttribute.EmailId)]
public string EmailId { get; set; }
// Custom mask to get valid email id from user.
[MaskAttribute("[A-Za-z0-9._%-]+@[A-Za-z0-9]+.[A-Za-z]{2,3}")]
public string EmailId { get; set; }
MaskAttribute(String, String)
Initializes a new instance of the MaskAttribute class with input mask.
Declaration
public MaskAttribute(string mask, string propertyName)
Parameters
Type | Name | Description |
---|---|---|
System.String | mask | The input mask for property. |
System.String | propertyName | The name of the property |
Examples
// Built-In mask to get valid email id from user.
[MaskAttribute(MaskAttribute.EmailId, "EmailId")]
public class Employee
{
public string EmailId { get; set; }
}
Fields
Alphanumeric
Gets the Regular expression for alpha numeric.
Declaration
public const string Alphanumeric = "[a-zA-Z0-9]*"
Field Value
Type |
---|
System.String |
Binary
Gets the Regular expression for binary.
Declaration
public const string Binary = "[01]*$"
Field Value
Type |
---|
System.String |
CardNumber
Gets the Regular expression for card number.
Declaration
public const string CardNumber = "\\d{4}-\\d{4}-\\d{4}-\\d{4}"
Field Value
Type |
---|
System.String |
EmailId
Regular expression to get valid email id from user.
Declaration
public const string EmailId = "[A-Za-z0-9._%-]+@[A-Za-z0-9]+.[A-Za-z]{2,3}"
Field Value
Type |
---|
System.String |
Fraction
Gets the Regular expression for fraction.
Declaration
public const string Fraction = "\\d*\\/\\d*"
Field Value
Type |
---|
System.String |
HexaDecimal
Gets the Regular expression for hexa decimal.
Declaration
public const string HexaDecimal = "\\\\x[0-9A-Fa-f]{1,2}"
Field Value
Type |
---|
System.String |
IPv4
Gets the Regular expression for IPv4.
Declaration
public const string IPv4 = "\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}"
Field Value
Type |
---|
System.String |
IPv6
Gets the Regular expression for IPv6.
Declaration
public const string IPv6 = "[0-9A-F]{4}:[0-9A-F]{4}:[0-9A-F]{4}:[0-9A-F]{4}:[0-9A-F]{4}:[0-9A-F]{4}:[0-9A-F]{4}:[0-9A-F]{4}"
Field Value
Type |
---|
System.String |
MobileNumber
Regular expression to get valid email id from user.
Declaration
public const string MobileNumber = "\\(?\\d{3}\\)?-? *\\d{3}-? *-?\\d{4}"
Field Value
Type |
---|
System.String |
Number
Gets the Regular expression for number.
Declaration
public const string Number = "\\d*"
Field Value
Type |
---|
System.String |
Octal
Gets the Regular expression for octal.
Declaration
public const string Octal = "\\\\0[0-7]{1,3}"
Field Value
Type |
---|
System.String |
PositiveNumber
Gets the Regular expression for positive number.
Declaration
public const string PositiveNumber = "\\d+"
Field Value
Type |
---|
System.String |
ProductKey
Gets the Regular expression for product key.
Declaration
public const string ProductKey = "[A-Z\\d]{5}-[A-Z\\d]{5}-[A-Z\\d]{5}-[A-Z\\d]{5}-[A-Z\\d]{5}"
Field Value
Type |
---|
System.String |
Properties
Mask
Gets or sets the input mask of MaskEditor, which is used to restrict and format input data.
Declaration
public string Mask { get; set; }
Property Value
Type |
---|
System.String |
Remarks
Provide regular expression as input mask, where user will be allowed to enter input that meets the expression. To know about regular expression, please refer https://docs.microsoft.com/en-us/dotnet/standard/base-types/regular-expression-language-quick-reference. Build-In mask are also available as constants, you can use it directly from MaskAttribute
Examples
// Built-In mask to get valid email id from user.
[MaskAttribute(MaskAttribute.EmailId, "EmailId")]
public class Employee
{
public string EmailId { get; set; }
}
// Built-In mask to get valid email id from user.
[MaskAttribute(MaskAttribute.EmailId)]
public string EmailId { get; set; }
// Custom mask to get valid email id from user.
[MaskAttribute("[A-Za-z0-9._%-]+@[A-Za-z0-9]+.[A-Za-z]{2,3}")]
public string EmailId { get; set; }
PropertyName
Gets or sets the property name to which MaskEditor will be applied.
Declaration
public string PropertyName { get; set; }
Property Value
Type |
---|
System.String |
Examples
// Built-In mask to get valid email id from user.
[MaskAttribute(MaskAttribute.EmailId, "EmailId")]
public class Employee
{
public string EmailId { get; set; }
}