我有一个Winforms PropertyGrid。
尝试在变量中设置值时。我想将一个错误抛给PropertyGrid,作为无效值后出现的错误。。

有办法这么做吗?
发布于 2013-05-23 10:01:37
您只需将throw作为set中的一个异常
private int someProperty;
public int SomeProperty {
get { return someProperty; }
set {
if((value % 3) != 0) throw new ArgumentOutOfRangeException(
"the value must be divisible by 3");
someProperty = value;
}
}生产:


https://stackoverflow.com/questions/16710745
复制相似问题