views:

85

answers:

2

[.NET 2]

Situation:

    class MyObject 
    {
        string Max { get{...}; set{...}; }
        string Min { get{...}; set{...}; }
    }

    MyObject myObj1 = new MyObject();
    // ... code
    txtMin.DataBindings.Add("Text", myObj1, "Min");
    txtMax.DataBindings.Add("Text", myObj1, "Max");

Problem:

Need verifying Min < Max before changing the property in MyObject.

If OK, change, if NOK, leave as is(maybe a message to the user).

(sorry if duplicate)

+2  A: 

Depends on what you want to do when validation fails (Min >= Max), you can use BindingComplete or Parse events from Binding.

Jacob Seleznev
A: 

In C# 3.5 it can be done with implementing custom ValidationRule.

sashaeve