Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个Winforms PropertyGrid.
Winforms PropertyGrid
尝试在变量中设置值时。我想将错误PropertyGrid作为输入无效值后出现的错误。
PropertyGrid
有办法做到这一点吗?
你只是throw一个例外set:
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; } }
产生: