开发者

How to bind a control boolean property to contrary of boolean application setting?

How to bind a control Boolean property to contrary of Boolean application setting?

For example I want to bind "Visible" property of a button to "!Flag开发者_如何学运维", that "Flag" is a Boolean field in application settings.


An ApplicationSetting binding doesn't allow applying any expression to the value. The simple solution is to derive your own control from Button. For example:

using System;
using System.Windows.Forms;

class MyButton : Button {
    public bool Invisible {
        get { return !Visible; }
        set { Visible = !value; }
    }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜