PowerTools MultiRow for Windows Forms 8.0J
ComparedOperator プロパティ (CompareValueBaseValidator)
使用例 

指定した値と比較する値の比較関係を示す値を取得または設定します。
構文
Public Property ComparedOperator As ValidateComparisonOperator
public ValidateComparisonOperator ComparedOperator {get; set;}

プロパティ値

ValidateComparisonOperator値の1つ。既定値はValidateComparisonOperator.GreaterThanです。
例外
例外解説
System.ComponentModel.InvalidEnumArgumentException指定された値がValidateComparisonOperator値の1つではありません。
使用例
次のサンプルコードは、CompareValueValidatorを使用して、元の値が10より大きいかどうかを検証します。入力モードに入って何らかの値を入力し、[Enter]キーを押して編集を終了します。その後で、[Esc]キーを押してCancelRowを発生させると、元の値が9であるため、検証が失敗してシステムサウンドが再生されます。このサンプルコードは、CellValidatorに示されている詳細なコード例の一部を抜粋したものです。
void setCompareValueValidator_Click(object sender, EventArgs e)
{
    Template template = Template.CreateGridTemplate(1);

    CompareValueValidator compareValueValidator = new CompareValueValidator();
    //You should set the RequiredType first, then set other Properties.
    compareValueValidator.RequiredType = typeof(int);
    compareValueValidator.ComparedValue = 10;
    compareValueValidator.DifferenceValue = 0;
    compareValueValidator.ComparedOperator = ValidateComparisonOperator.GreaterThan;
    
    SoundNotify soundNotify = new SoundNotify();
    soundNotify.SoundType = SystemSoundType.Asterisk;
    //When cancel the whole Row editing, the old value will be restored.
    soundNotify.DoActionReason = ValidateReasons.CancelRow;

    compareValueValidator.Actions.Add(soundNotify);

    //When do the SoundNotify action, this value 9 will be validated.
    template.Row.Cells[0].Value = 9;
    template.Row.Cells[0].Validators.Add(compareValueValidator);

    this.gcMultiRow1.Template = template;
    label.Text = "The CompareValueValidator.ComparedValue is 10, DifferenceValue is 0, ComparedOperator is GreaterThan, input some value to Cell, press ENTER to commit value(not validate), then press ESC to trigger validation(DoActionReason is CancelRow), the old value 9 is restored and validated, validation failed, one Sound will be played";
}
Private Sub setCompareValueValidator_Click(ByVal sender As Object, ByVal e As EventArgs) Handles setCompareValueValidator.Click
    Dim template As Template = template.CreateGridTemplate(1)

    Dim compareValueValidator As New CompareValueValidator()
    'You should set the RequiredType first, then set other Properties.
    compareValueValidator.RequiredType = GetType(Integer)
    compareValueValidator.ComparedValue = 10
    compareValueValidator.DifferenceValue = 0
    compareValueValidator.ComparedOperator = ValidateComparisonOperator.GreaterThan

    Dim soundNotify As New SoundNotify()
    soundNotify.SoundType = SystemSoundType.Asterisk
    'When cancel the whole Row editing, the old value will be restored.
    soundNotify.DoActionReason = ValidateReasons.CancelRow

    compareValueValidator.Actions.Add(soundNotify)

    'When do the SoundNotify action, this value 9 will be validated.
    template.Row.Cells(0).Value = 9
    template.Row.Cells(0).Validators.Add(compareValueValidator)

    Me.gcMultiRow1.Template = template
    label.Text = "The CompareValueValidator.ComparedValue is 10, DifferenceValue is 0, ComparedOperator is GreaterThan, input some value to Cell, press ENTER to commit value(not validate), then press ESC to trigger validation(DoActionReason is CancelRow), the old value 9 is restored and validated, validation failed, one Sound will be played"
End Sub
参照

CompareValueBaseValidator クラス
CompareValueBaseValidator メンバ

 

 


© 2008-2015 GrapeCity inc. All rights reserved.