Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 467241
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T23:33:39+00:00 2026-05-12T23:33:39+00:00

Winforms .net 3.5 app. In my app I have a generic class that looks

  • 0

Winforms .net 3.5 app. In my app I have a generic class that looks like so:

public class FilterItem {
  public FilterItem() { }
  public string FilterProperty { get; set; }
  public bool FilterPropertyChecked { get; set; }
  public ComparitiveOperator FilterOperator { get; set; }
  public string FilterValue { get; set; }
}

and I use it in all of my dialog boxes when I want to implement some sort of filter functionality. So I call the dialog form with a pre-poulated List<FilterItem> passed in the constructor. Now when the dialog loads, it iterates thru each list-item and adds:

  1. A checkbox
  2. A combobox
  3. A textbox

to every row in a TableLayoutPanel. The Checkbox gets its text property from FilterProperty and its Checked status from FilterPropertyChecked…the Combobox gets its binding from FilterOperator…and the Textbox gets its text value from FilterValue.

Notice how Im only saying gets. What I would like to do is automatically update these properties when the Controls whose properties they are bound to change. I heard about ObservableCollection<T> but I dont seem to have ‘access’ to it in Winforms after adding the System.Collections.ObjectModel namespace.

What would be the best way to accomplish this. BindingList with INotifyPropertyChanged?? Im not an expert with the latter, and would greatly appreciate some pointers – if this is the way I should be going.

thank u!

EDIT:

Ok, let me post some code to show what I think I should be doing :). I know I need to implement INotifyPropertyChanged on my FilterItem class, so (just for the FilterValue part for example):

public class FilterItem : INotifyPropertyChanged {
    public FilterItem() { }
    public string FilterProperty { get; set; }
    public bool FilterPropertyChecked { get; set; }
    public ComparitiveOperator FilterOperator { get; set; }

    private string _FilterValue;
    public string FilterValue {
        get { return this._FilterValue; }
        set {
            if (this._FilterValue != value) {
                this._FilterValue = value;
                this.OnFilterValueChanged();
            }
        }
    }

    #region INotifyPropertyChanged Members
    protected void OnFilterValueChanged() {
        var handler = this.PropertyChanged;
        if (handler != null) {
            handler(this, new PropertyChangedEventArgs("FilterValue"));
        }
    }
    public event PropertyChangedEventHandler PropertyChanged;
    #endregion
}

Now it should all come together in my Form_Load (this is just for the Textbox part and I have omitted the Checbox and ComboBox) like so:

private List<FilterItem> FilterList; // <-- this gets assigned to in the constructor

private void dlgFilterData_Load(object sender, EventArgs e) {
    foreach (FilterItem item in FilterList) {
        txt = new TextBox();
        txt.DataBindings.Add("Text", item, "FilterValue", false, DataSourceUpdateMode.OnPropertyChanged);
        txt.Dock = DockStyle.Fill;
    }
}

the textbox’s databindings DataSource is the FilterItem ‘item’. But now I seem to be having a problem with my visual studio IDE, so cant try this out, but will when I have it up and running. What I would like to know now is: will this setup successfully assist in allowing my individual FilterItems to get automatically updated when their assigned Control’s respective property changes??

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T23:33:39+00:00Added an answer on May 12, 2026 at 11:33 pm

    The ObservableCollection class is in the WindowsBase assembly, so you’d need to add WindowsBase to your project references to “access” it.

    That being said, I don’t think ObservableCollection is going to give you everything you want. Your bound control will get notified when you add or remove items, but there is no automatic property change notification, which is what it sounds like you want.

    Regardless of what sort of collection you end up using, I think you’re on the right track with INotifyPropertyChanged. Here’s a simple example of implementing INotifyPropertyChanged:

    class Foo : INotifyPropertyChanged
    {
        #region Bar property
    
        private string _bar;
        public string Bar
        {
            get { return _bar; }
            set
            {
                if (_bar != value)
                {
                    _bar = value;
    
                    OnPropertyChanged("Bar");
                }
            }
        }
    
        #endregion
    
        protected void OnPropertyChanged(string name)
        {
            var handler = PropertyChanged;
    
            if (handler != null)
                handler(this, new PropertyChangedEventArgs(name));
        }
    
        public event PropertyChangedEventHandler PropertyChanged;
    }
    

    Basically, any time a property of your object changes, fire the PropertyChanged event, passing the name of the property that changed.

    Finally, all of this may be moot, because you said that you want to change the value of an object’s property in response to a change to a control bound to that property. The usual Windows Forms data binding infrastructure can make that happen without the help of INotifyPropertyChanged or any other interface. You only need to implement INotifyPropertyChanged if you need to notify a bound control of changes to your object’s properties from elsewhere.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have an MSI installer for a .Net WinForms app for Windows XP that
I have a WinForms .NET app that, according to the Vista Task Manager with
I have a .NET Winforms app (created in VS2005) that I deploy using ClickOnce.
We have a .NET 2.0 winforms app that connects to a SQL Server 2005
I have this app written in VB.Net with winforms that shows some stats and
I have a .net winforms app which has a few animation effects, fade ins
I've got a VB.NET WinForms app in which I have the need to refer
I have created a setup project in VS2008. My WinForms app uses .NET 2.0,
I have a WinForms app written in C# with .NET 3.5. It runs a
I have a legacy WinForms Mdi App in VB.Net 2.0 which I am adding

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.