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

  • Home
  • SEARCH
  • 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 489675
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T01:49:56+00:00 2026-05-13T01:49:56+00:00

I have the following classes: public class MyItems : List<MyItem> { … } public

  • 0

I have the following classes:

public class MyItems : List<MyItem>
{
...
}

public class MyItem
{
...
}

I’ve instantiated MyItems and assigned it to the DataSource property of a WinForms datagrid.

Everything displays properly, but when I try to add rows, nothing happens. What I do is case the grids DataSource back to MyItems, add an instance of MyItems to it, and then set the DataSource back to the list. I can step through the code and see that the count of items in the datasource is growing, but the grid isn’t displaying them. Any ideas?

//Form Load
MyItems lstItems = new MyItems();
lstItems.Add(new MyItem("1"));
lstItems.Add(new MyItem("2"));

//Grid displays two rows;
grd.DataSource = lstItems;

//Add button click event
MyItems lstItmes = (MyItems)grd.DataSource;
lstItems.Add(new MyItem("3"));

//Grid does not display new row
grd.DataSource = lstItems;
  • 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-13T01:49:56+00:00Added an answer on May 13, 2026 at 1:49 am

    In order for changes to the data source to show up, it must implement the System.ComponentModel.IBindingList interface. This is the interface that provides the ListChanged event, which is what the grid hooks into in order to discover changes to the list (adding and removing items) or to rows (changing property values).

    Additionally, the ITypedList interface is what allows the designer to discover properties and how the grid can perform data binding with better performance than reflection-based binding.

    If you’re just looking for basic notifications and your base class already inherits from something like List<T>, try changing the parent to System.ComponentModel.BindingList<T>. This has a simple implementation of the IBindingList interface already. You’ll have to do more work if you want more advanced things like sorting or support property change notification, but it provides the implementation for basic adding and removing.

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

Sidebar

Related Questions

If I have the following classes: public class MyItems : List<MyItem> { .. }
I have the following classes: public class Person { public String FirstName { set;
I have the following classes public interface InterfaceBase { } public class ImplementA:InterfaceBase {
I have following classes. class A { public: void fun(); } class B: public
I have following classes: public abstract class CustomerBase { public long CustomerNumber { get;
I have the following classes : public abstract class Item { //... } public
I have two following classes: public class User { public virtual Guid Id {
I have the following classes: Public Class Email Private Shared ReadOnly EMAIL_REGEX = \b[a-zA-Z]+[a-zA-Z0-9._+-]+@
I have the following classes: Ingredients, Recipe and RecipeContent... class Ingredient(models.Model): name = models.CharField(max_length=30,
I have the following 3 classes Book Product SpecialOptions There are many Books, and

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.