Eric's Blog

Day to day experience in .NET
Welcome to Blogs @ IRM Sign in | Join | Help
 Search

Disclaimer

The content of this site is my own personal opinion and does not in any way represent my employer, it's subsideries or affiliates. These postings are provided "AS IS" with no warranties, and confer no rights.

This Blog

Binding Visible Property Often Requires Workaround

I haven't managed to bind the Visible property of Windows Forms controls and getting it to work. I belive that it does not work because the property that I bind to returns false initially and therefor are the control never created, and the data binding of the control is not active if the control is not created (because of optimization). This is easy to workaround though, by creating a property in the Form that sets the Visible property on the control and then bind this property.

public bool IsPersonEmployee
{
    get { return this.worklocationLabel.Visible; }
    set
    {
        this.worklocationLabel.Visible = value;
        this.workLocationsCheckedListBox.Visible = value;
    }
}
DataBindings.Add("IsPersonEmployee", this.presenterBindingSource, "IsPersonEmployee");
Published den 13 februari 2009 14:21 by ericqu

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

 

Eric's Blog said:

Lately I’ve been using Model-View-ViewModel (MVVM) in Windows Forms application with great success. I

augusti 8, 2009 10:42
 

Jason said:

This still seems to be a problem with .NET 4.0. But this solution is the best work around that I've found. thanks
maj 4, 2012 16:38

Leave a Comment

(required) 
(optional)
(required) 
Submit
Powered by Community Server, by Telligent Systems