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 8168189
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T20:26:18+00:00 2026-06-06T20:26:18+00:00

I know I should be able to solve this myself, but I’ve been banging

  • 0

I know I should be able to solve this myself, but I’ve been banging my head on the desk for hours.

I have a list of items in a DGV, and want the DGV to update when the properties change (one property in this case). Below is a complete sample that reproduces the problem. The output of the program is:

Marking item 'One' as Missing
Status changing
Status changed has a listener
Marking item 'Two' as Missing
Status changing
Marking item 'Three' as Missing
Status changing
Marking item 'Four' as Missing
Status changing

You see the change occur on the DGV only for the first item. As you can see from that output, the BindingSource is listening for property changes on the first item in the list and passing notice to the DGV, but not for any of the others.

What am I missing here?

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Windows.Forms;

class Form1 : Form
{
    private enum ModuleStatus
    {
        Ok,
        Missing,
    }

    private sealed class ModuleInfo : INotifyPropertyChanged
    {
        public string Label { get; set; }
        private ModuleStatus _status;
        public ModuleStatus Status
        {
            get { return _status; }
            set
            {
                if (_status != value)
                {
                    Trace.WriteLine(String.Format("Status changing"));
                    _status = value;
                    OnPropertyChanged("Status");
                }
            }
        }

        public event PropertyChangedEventHandler PropertyChanged;

        private void OnPropertyChanged(string propertyName)
        {
            PropertyChangedEventHandler handler = PropertyChanged;
            if (handler != null)
            {
                Trace.WriteLine(String.Format("Status changed has a listener"));
                handler(this, new PropertyChangedEventArgs(propertyName));
            }
        }
    }

    private List<ModuleInfo> moduleList = new List<ModuleInfo>();
    private BindingSource moduleBinding;
    private Timer timer = new Timer { Enabled = true, Interval = 1000 };

    public Form1()
    {
        moduleBinding = new BindingSource(moduleList, null);
        Controls.Add(new DataGridView
        {
            Dock = DockStyle.Fill, AutoGenerateColumns = false, AllowUserToAddRows = false, RowHeadersVisible = false,
            Columns =
                {
                    new DataGridViewTextBoxColumn { HeaderText = "Label", DataPropertyName = "Label", AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill, ReadOnly = true },
                    new DataGridViewTextBoxColumn { HeaderText = "Status", DataPropertyName = "Status", ReadOnly = true  },
                },
            DataSource = moduleBinding,
        });

        foreach (string label in new string[] { "One", "Two", "Three", "Four" })
            moduleBinding.Add(new ModuleInfo { Label = label, Status = ModuleStatus.Ok });

        timer.Tick += new EventHandler(timer_Tick);
    }

    int modifyIndex = 0;
    void timer_Tick(object sender, EventArgs e)
    {
        if (modifyIndex < moduleList.Count)
        {
            Trace.WriteLine(String.Format("Marking item '{0}' as Missing", moduleList[modifyIndex].Label));
            moduleList[modifyIndex].Status = ModuleStatus.Missing;
            modifyIndex++;
        }
    }

    [STAThread]
    static void Main()
    {
        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);
        Application.Run(new Form1());
    }
}
  • 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-06-06T20:26:20+00:00Added an answer on June 6, 2026 at 8:26 pm

    change your moduleList to this:

    private BindingList<ModuleInfo> moduleList = new BindingList<ModuleInfo>();
    

    you may or may not find this post helpful: BindingList vs List

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

Sidebar

Related Questions

I know this should be a basic question but I am hitting a brick
I know there should be a simple fix for this, but im braindead at
I have been struggling with this seeminly easy problem for 48 hours, and I
I feel like this is something that Google should be able to solve for
I know I should do my homework on my own but I simply can't
I know you should use a StringBuilder when concatenating strings but I was just
I know it should be a fairly easy thing to do but for some
( I don't know whether should I also post this question to ServerFault, since
I know there are actually a number of questions similar to this one, but
I have a requirement where users should be able to navigate from the first

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.