Cannot data bind to a control when Control.Visible == false

后端 未结 7 646
独厮守ぢ
独厮守ぢ 2020-12-14 11:22

In WinForms with C# 4.0 / C# 2.0, I cannot bind to a control if the control\'s visible field is false:

this.checkBox_WorkDone.DataBindings.Add(\"Visible\", W         


        
7条回答
  •  醉梦人生
    2020-12-14 12:06

    What you could do is make the control visible, and make it invisible again once the binding has changed.

    this.checkBox_WorkDone.Visible = true; 
    this.checkBox_WorkDone.BindingContextChanged += (object sender, EventArgs e) => {
        this.checkBox_WorkDone.Visible = false; 
    };
    

    Not very pretty, but it works.

提交回复
热议问题