Version

RegexPattern Property

Gets/sets a regular expression to which the cell values must conform. All of the characters in the cell's text must be a part of the match for validation to succeed.
Syntax
'Declaration
 
Public Property RegexPattern As String
public string RegexPattern {get; set;}
Remarks

The regular expression given to this property will be used during validation of the cell values in the column. As the user attempts to move the input focus out of the cell, the text in the cell will be validated against the regular expression. For the validation to succeed, all of the text in the cell must constitute a single match. If the cell contains a match and other characters then the validation will fail. For example, if the regular expression is "\d{2}" (meaning, two consecutive digit characters) and the cell's text is "12" then the validation will succeed. However, if the cell's text is "123" then the validation will fail because of the extra digit ("3") that follows the match ("12"). This behavior can be altered by appending or prepending ".*" to the regular expression, meaning that any number of characters can precede or follow the target match.

Example
This snippet demonstrates how the RegexPattern property on the UltraGridColumn can be used to restrict the values that the user can enter into the cells of a column.

Private Sub SetupGrid()
   ' Create a regular expression pattern which only matches a sequence of characters that starts
   ' with one to three digits followed by a single character.
   ' That is the pattern required for Order IDs in this example.
   '
   Dim strRegex As String = "\d{1,3}\w"
   
   ' Assign the regular expression pattern to the RegexPattern property of the OrderID column.
   '
   Me.ultraGrid1.DisplayLayout.Bands("Orders").Columns("OrderID").RegexPattern = strRegex
End Sub
private void SetupGrid()
{
	// Create a regular expression pattern which only matches a sequence of characters that starts
	// with one to three digits followed by a single character.
	// That is the pattern required for Order IDs in this example.
	//
	string strRegex = @"\d{1,3}\w";

	// Assign the regular expression pattern to the RegexPattern property of the OrderID column.
	//
	this.ultraGrid1.DisplayLayout.Bands["Orders"].Columns["OrderID"].RegexPattern = strRegex;
}
Requirements

Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2012, Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also