Version

Value Property (UltraCurrencyEditor)

Gets/sets the control's current value.
Syntax
'Declaration
 
Public Property Value As Decimal
public decimal Value {get; set;}
Remarks

The UltraCurrencyEditor control provides the ability to restrict the range of values that will be accepted by the control. This is accomplished by setting the MinValue and MaxValue properties.

When the control loses focus with a value that is outside the range determined but the MinValue and MaxValue properties, the UltraNumericEditorBase.ValidationError event is raised.

Example
This sample shows how to set the Min/Max value properties and also how to handle when a value is entered that exceeds the aforementioned boundaries by using the ValidationError event.

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

     Me.UltraCurrencyEditor1.MaxValue = 10000
     Me.UltraCurrencyEditor1.MinValue = 0

 End Sub

 Private Sub UltraCurrencyEditor1_ValidationError(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinEditors.ValidationErrorEventArgs) Handles UltraCurrencyEditor1.ValidationError

     e.Beep = True

' We want to get the value currently being edited.
' To do that we must get the embeddableUIElement.
     Dim embeddableEditorUI As Infragistics.Win.EmbeddableUIElementBase = Me.UltraCurrencyEditor1.UIElement.GetDescendant(GetType(Infragistics.Win.EmbeddableUIElementBase))
     If Not embeddableEditorUI Is Nothing Then

		' Now that we have embeddable element, get current edit text.
         Dim editText As String = embeddableEditorUI.Editor.CurrentEditText
         Dim editValue As Decimal = 0
		
         Try
			' In order to do comparison we want to get this text
			' into a decimal. 
			' Strip out the prompt chars, spaces, currency and group symbols.
             editText = editText.Replace(Me.UltraCurrencyEditor1.PromptChar.ToString(), "")
             editText = editText.Replace(" ", "")
             editText = editText.Replace(System.Globalization.NumberFormatInfo.CurrentInfo.CurrencySymbol, "")
             editText = editText.Replace(System.Globalization.NumberFormatInfo.CurrentInfo.CurrencyGroupSeparator, "")
             editValue = Decimal.Parse(editText)

             Dim over As Boolean = editValue > Me.UltraCurrencyEditor1.MaxValue
             Dim errorText As String
             If (over) Then
                 errorText = "The current value is greater than the maximum value"
             Else
                 errorText = "The current value is less than the minimum value"
             End If
             MessageBox.Show(Me, errorText, "Value does not fit "
         Catch

         End Try
     End If

 End Sub
private void Form1_Load(object sender, System.EventArgs e)
{

	this.ultraCurrencyEditor1.MaxValue = 10000;
	this.ultraCurrencyEditor1.MinValue = 0;

}

private void ultraCurrencyEditor1_ValidationError(object sender, Infragistics.Win.UltraWinEditors.ValidationErrorEventArgs e)
{

	e.Beep = true;

	// We want to get the value currently being edited.
	// To do that we must get the embeddableUIElement.
	Infragistics.Win.EmbeddableUIElementBase embeddableEditorUI = this.ultraCurrencyEditor1.UIElement.GetDescendant(typeof(Infragistics.Win.EmbeddableUIElementBase)) as Infragistics.Win.EmbeddableUIElementBase;

	if(null != embeddableEditorUI)
	{
		//	Now that we have embeddable element, get current edit text.
		string editText = embeddableEditorUI.Editor.CurrentEditText ;
		decimal editValue = 0m;

		try
		{
			// In order to do comparison we want to get this text
			// into a decimal. 
			// Strip out the prompt chars, spaces, currency and group symbols.
			editText = editText.Replace(this.ultraCurrencyEditor1.PromptChar.ToString(),"");
			editText = editText.Replace(" ","");
			editText = editText.Replace(System.Globalization.NumberFormatInfo.CurrentInfo.CurrencySymbol,"");
			editText = editText.Replace(System.Globalization.NumberFormatInfo.CurrentInfo.CurrencyGroupSeparator,"");
			editValue = decimal.Parse(editText);
			
			bool over = editValue > this.ultraCurrencyEditor1.MaxValue;
			string errorText;

			if(over)
				errorText = "The current value is greater than the maximum value";
			else
				errorText = "The current value is less than the minimum value";

			MessageBox.Show(this,errorText,"Value does not fit ");
		}
		catch
		{}
	}	

}
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