Infragistics(R) NetAdvantage(R) Windows Forms
RegexPattern Property
See Also  Example E-mail your feedback on this topic.
Infragistics.Win.UltraWinGrid Namespace > UltraGridColumn Class : 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

Visual Basic (Declaration) 
Public Property RegexPattern As String
C# 
public string RegexPattern {get; set;}

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.

Visual BasicCopy Code
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
C#Copy Code
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;
}

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.

See Also