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

指定した値の上限を取得または設定します。
構文
Public Property MaxValue As Object
public object MaxValue {get; set;}

プロパティ値

指定した値の上限を表すSystem.Object値。
例外
例外解説
System.ArgumentOutOfRangeException指定された値がMinValue未満です。
解説
RequiredTypeが指定されていない場合、MaxValueは、所有元のCellCell.ValueTypeまたはCell.FormattedValueType(ValueTypeがnull 参照 (Visual Basicでは Nothing)の場合)に変換されます。
使用例
次のサンプルコードは、RangeValidatorを使用して、コミットされた値がMinValueMaxValueの間にあるかどうかを検証します。入力モードに入って「49」(範囲外)と入力し、[Enter]キーを押して編集を終了すると、検証が失敗したことを示す赤の下線が表示されます。「55」(範囲内)と入力して[Enter]キーを押した場合は、検証が成功し、下線は表示されません。このサンプルコードは、CellValidatorに示されている詳細なコード例の一部を抜粋したものです。
void setRangeValidator_Click(object sender, EventArgs e)
{
    Template template = Template.CreateGridTemplate(1);

    //Create one RangeValidator to vaidate whether the committed value is between one range.
    RangeValidator rangValidator = new RangeValidator();
    //You should set the RequiredType first, then set other Properties.
    rangValidator.RequiredType = typeof(int);
    rangValidator.MinValue = 5;
    rangValidator.MaxValue = 10;
    rangValidator.NullIsValid = false;

    LineNotify lineNotifyAction = new LineNotify();
    //When you ends edit mode, the action will be done.(press Enter key commonly)
    lineNotifyAction.DoActionReason = ValidateReasons.EndEdit;
    lineNotifyAction.LineColor = Color.Red;

    rangValidator.Actions.Add(lineNotifyAction);

    template.Row.Cells[0].Validators.Add(rangValidator);

    this.gcMultiRow1.Template = template;
    label.Text = "The RangeValidator's MinValue is 5, MaxValue is 10, input 4(not between the range) in one Cell, press Enter key to trigger validation(DoActionReason is EndEdit), one red under line will be shown.";
}
Private Sub setRangeValidator_Click(ByVal sender As Object, ByVal e As EventArgs) Handles setRangeValidator.Click
    Dim template As Template = template.CreateGridTemplate(1)

    'Create one RangeValidator to vaidate whether the committed value is between one range.
    Dim rangValidator As New RangeValidator()
    'You should set the RequiredType first, then set other Properties.
    rangValidator.RequiredType = GetType(Integer)
    rangValidator.MinValue = 5
    rangValidator.MaxValue = 10
    rangValidator.NullIsValid = False

    Dim lineNotifyAction As New LineNotify()
    'When you ends edit mode, the action will be done.(press Enter key commonly)
    lineNotifyAction.DoActionReason = ValidateReasons.EndEdit
    lineNotifyAction.LineColor = Color.Red

    rangValidator.Actions.Add(lineNotifyAction)

    template.Row.Cells(0).Validators.Add(rangValidator)

    Me.gcMultiRow1.Template = template
    label.Text = "The RangeValidator's MinValue is 5, MaxValue is 10, input 4(not between the range) in one Cell, press Enter key to trigger validation(DoActionReason is EndEdit), one red under line will be shown."
End Sub
参照

RangeValidator クラス
RangeValidator メンバ

 

 


© 2008-2015 GrapeCity inc. All rights reserved.