Οκ έχω κάτι δύσκολο, ελπίζω να το ξέρει κάποιος.
Έχω ενα Property σε ενα Class που κάτω απο ορισμένες συνθίκες throws ένα Exception ο Κώδικας του 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;
}
}
Στην Οθόνη μου κάνω Bind ενός CheckBox με το Property του Class μου ο κώδικας:
Binding adminBind = new Binding("Checked", user, "IsAdministrator");
this.chkIsAdmin.DataBindings.Add(adminBind);
Όταν το Property throws το Exception το control δεν φευγει απο Focused και λοκαρι την οθόνη χωρίς μήνυμα!!
Προσπάθησα να πίασω το DataError Event του BindManager κώδικας :
BindingManagerBase adminManager = this.BindingContext[user, "IsAdministrator"];
adminManager.DataError += new BindingManagerDataErrorEventHandler(adminManager_DataError);
Αλλα τίποτα
Έχει καποιος καμία ιδέα για το πώς θα πιασω το Exception???
thnx in Advance
Nassos
"Success is the ability to go from one failure to another with no loss of enthusiasm."
Winston Churchill
"Quality means doing it right when no one is looking."
Henry Ford