バージョン

MaxValue プロパティ (UltraCurrencyEditor)

コントロールが保持できる最大値を取得または設定します。
シンタックス
'宣言
 
Public Property MaxValue As Decimal
public decimal MaxValue {get; set;}
解説

UltraCurrencyEditor コントロールは、コントロールによって認められる値の範囲を制限する機能を提供します。これは、MinValue プロパティとMaxValueプロパティを設定することによって行います。

MinValue および MaxValue プロパティで決定された範囲外にある値でコントロールがフォーカスを失うと、UltraNumericEditorBase.ValidationError イベントが発生します。

使用例
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
		{}
	}	

}
参照