Catching the Exception thrown from a property that change throu DataBinding [modified]
-
Hello All, i have a property in my DataClass and i bound it to a control
Binding adminBind = new Binding("Checked", user, "IsAdministrator"); this.chkIsAdmin.DataBindings.Add(adminBind);
this Property throw an Exception when some conditions not meet (this code is inside the set of the Property).public bool IsAdministrator { get { return Convert.ToBoolean(_Record.WL_ISADMIN.Value); } set { //If the New value is true if (value) { if (CanBeTheUserAdmin())//Check if the Garage Has Admin User { //No Admin User, This Becomes Admin _Record.WL_ISADMIN.Value = value; } else//If the Garage Has Admin User throw Exception throw new Exception("Δεν Μπορείτε να κάνετε τον Χρήστη Administrator διότι Υπαρχει ήδη Administrator για το Συνεργείο!!"); }else//If the New value is False, applying it to the user _Record.WL_ISADMIN.Value = value; } }
right now when the exception is thrown the control just DON'T lose Focus, and the user get confused. How can i cath the Exception in order to show the Exception Message to the User?? Any Saggestion is most Wellcome! Nassos -- modified at 7:41 Thursday 16th November, 2006GanDad