
Raising "Invalid Property Values"
Quote:
> I already try the suggestion bellow and it works, but how can if I
> want to throw
> the exception from the TypeConverter Class, I already try to throw it
> from the TypeConverter but there is no exception raised.
raised from the Int32Converter Class and not
Quote:
> from the component class.
This works for me:
namespace WindowsApplication3 {
public class UserControl1 : System.Windows.Forms.UserControl {
int MyPropValue;
[TypeConverterAttribute("WindowsApplication3.MyTypeConverter")]
public int MyProperty {
get {
return MyPropValue;
}
set {
MyPropValue = value;
}
}
Quote:
}
public class MyTypeConverter : System.ComponentModel.Int32Converter {
public override object
ConvertFrom(System.ComponentModel.ITypeDescriptorContext context,
System.Globalization.CultureInfo culture, object value) {
int intvalue = (int) base.ConvertFrom(context, culture, value) ;
if (intvalue < 1 || intvalue > 15) throw(new
Exception(value.ToString() + " is not a valid value for " +
context.PropertyDescriptor.Name + " property"));
return intvalue;
Quote:
}
--
Eduardo A. Morcillo (MS MVP VB)
http://www.domaindlx.com/e_morcillo