GrapeCity MultiRow Windows Forms Documentation
DifferenceValue Property
Example 


Gets or sets the difference between the specified and compared values.
Syntax
<EditorAttribute(EditorBaseTypeName="System.Drawing.Design.UITypeEditor, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", EditorTypeName="GrapeCity.Win.MultiRow.Design.ValidatorDifferenceValueTypeEditor,GrapeCity.Win.MultiRow.Design, Version=7.20.20141.0, Culture=neutral, PublicKeyToken=0f7a722ee3c2bdd9")>
<SRDescriptionAttribute("Indicates the difference value of the specified value and compared value.")>
<TypeConverterAttribute("GrapeCity.Win.MultiRow.Design.ValidatorDifferenceValueTypeConverter, GrapeCity.Win.MultiRow, Version=7.20.20141.0, Culture=neutral, PublicKeyToken=0f7a722ee3c2bdd9")>
<DefaultValueAttribute()>
Public Property DifferenceValue As Object
Dim instance As CompareValueBaseValidator
Dim value As Object
 
instance.DifferenceValue = value
 
value = instance.DifferenceValue
[Editor(EditorBaseTypeName="System.Drawing.Design.UITypeEditor, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", EditorTypeName="GrapeCity.Win.MultiRow.Design.ValidatorDifferenceValueTypeEditor,GrapeCity.Win.MultiRow.Design, Version=7.20.20141.0, Culture=neutral, PublicKeyToken=0f7a722ee3c2bdd9")]
[SRDescription("Indicates the difference value of the specified value and compared value.")]
[TypeConverter("GrapeCity.Win.MultiRow.Design.ValidatorDifferenceValueTypeConverter, GrapeCity.Win.MultiRow, Version=7.20.20141.0, Culture=neutral, PublicKeyToken=0f7a722ee3c2bdd9")]
[DefaultValue()]
public object DifferenceValue {get; set;}

Property Value

A System.Object that represents the difference between the specified and compared values. The default is a null reference (Nothing in Visual Basic).
Remarks
The validated value subtracts the compared value. You can compare the result with the DifferenceValue.
Example
The following code example uses the CompareValueValidator to validate whether the original value is greater than 10. A system sound plays to notify you the validation failed. Enter edit mode, type a value, and then press the Enter key to end the edit. Press the Esc key to trigger the CancelRow event. The validation fails because the original value was 9. This example is part of a larger example available for the CellValidator class.
void setCompareValueValidator_Click(object sender, EventArgs e)
        {
            Template template = Template.CreateGridTemplate(1);

            CompareValueValidator compareValueValidator = new CompareValueValidator();
            //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 cancelling the entire row's editing, the old value is restored.
            soundNotify.DoActionReason = ValidateReasons.CancelRow;

            compareValueValidator.Actions.Add(soundNotify);

            //When using the SoundNotify action, the value 9 is 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 a value in the Cell, press ENTER to commit the value (not validate), then press ESC to trigger 
validation (DoActionReason is CancelRow), the old value 9 is restored and validated, validation fails, a sound is 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()
        '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 cancelling the entire row's editing, the old value is restored.
        soundNotify.DoActionReason = ValidateReasons.CancelRow

        compareValueValidator.Actions.Add(soundNotify)

        'When using the SoundNotify action, the value 9 is 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 a value in the 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 fails, a sound is played"
    End Sub
Requirements

Target Platforms: 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

Reference

CompareValueBaseValidator Class
CompareValueBaseValidator Members

 

 


Copyright © GrapeCity, inc. All rights reserved.