【发布时间】:2012-11-21 00:25:36
【问题描述】:
我想根据 MyPropertySelected 显示 MyProperty1 或 MyProperty2。如何使用基于MyPropertySelected的条件语句if或else?谢谢。
// [Browsable(true)
// ????? conditional statement IF ELSE in here..
// IF (MyPropertySelected) MyProperty1 will be show ELSE MyProperty2 will be show.
public bool MyPropertySelected { get; set; }
// [Browsable(true) or [Browsable(false) depending on MyPropertySelected condition.
public int MyProperty1 { get; set; }
// [Browsable(true) or [Browsable(false) depending on MyPropertySelected condition.
public int MyProperty2 { get; set; }
【问题讨论】:
-
不清楚,你想怎么使用属性...
-
我希望将以上属性绑定到属性网格,条件如下:MyPropertySelected 始终可浏览(true)。如果我在属性网格上将 MyPropertySelected 值选择为 true,则 MyProperty1 将设置为 Browsable(true),将 MyProperty2 设置为 MyProperty2 到 Browsable(false)。
标签: c# winforms properties attributes conditional-operator