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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T22:06:55+00:00 2026-05-24T22:06:55+00:00

We are Java developers trying to support a project in C# and can’t seem

  • 0

We are Java developers trying to support a project in C# and can’t seem to figure out how to bind a list of objects which is constantly being updated in and by the UI to a DataGridView so they are visible as soon as they are added.

There is a requirement that the UI track its use and display it back to the user in a data grid (for human factors analysis). We are implementing the IList interface and subclassing one of our logging classes:

public class DataSourceAppender : Logger, IList<LogEvent>
{
    private List<LogEvent> _events = new List<LogEvent>();

We add (append) a new LogEvent object to the list each time the user clicks a control or performs some operation of interest, recording various details of the interaction in the order in when they occurred. This list is dumped to a file at the end of the user test session for analysis. Now we need to show this to the user in a data grid as the session is progressing.

Our main method contains:

// create a new logger(appender) which holds all our log events
consoleSource = new DataSourceAppender();
consoleSource.Append("INIT", "Client Initialized");

// add the logger the the console data grid and wire-up the data binding
mainform.consoleDataGrid.AutoGenerateColumns = true;
mainform.consoleBinding.DataSource = typeof(LogEvent);
mainform.consoleBinding.DataSource = consoleSource;
consoleSource.Binding = mainform.consoleBinding;

The append method in the DataSourceAppender (a.k.a consoleSource) contains:

public override void Append(string category, object entry)
{
    long now = (System.DateTime.Now.Ticks - 621355968000000000) / 10000;

    if (lastevent == 0) lastevent = now;

    try
    {
        LogEvent logevent = new LogEvent(now, category, (now - lastevent), Log.Interval, entry);

        // add the new log event to this data sorce
        lock (_events)
        {
            _events.Add(logevent);
        }
        if (_binding != null) _binding.ResetBindings(false);
    }
    catch (Exception e)
    {
        System.Console.Error.WriteLine(this.GetType().FullName + " error: " + e + ":" + e.Message);
    }
}

The results are the first “INIT” entry is displayed in the data grid but none of the other events in the DataSourceAppender (a.k.a consoleSource) are displayed. They are all written to disk later so we know the Append method is getting called and otherwise working fine.

A few goals:

  • We are trying to stick to the Designer and not mess with generated code.
  • We would like to wire up the binding in the Main() method.
  • We would like the public properties of the LogEvent class to appear as column headings
  • This must remain a single-threaded application

We have been scouring forums and the MSDN pages and find loads of examples for binding to databases and manually updating the data grid, but precious little information on programmatically adding data to the data grid through its backing data store.

Any help would be greatly appreciated.

  • 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-24T22:06:56+00:00Added an answer on May 24, 2026 at 10:06 pm

    Since we can’t see your entire DataSourceAppender class, I can’t tell for sure what you’re trying to do.

    I see you’ve assigned consoleSource as your datasource, so the fact that you’re not seeing any newly added items in the grid tells me you haven’t correctly implemented IList to wrap _events;

    But you’re making life harder than necessary by trying to implement IList anyway. Just assign _events as your datasource. If you like, you can expose it as a property of DataSourceAppender:

    public IEnumerable<LogEvent> EventList { get { return _events; } }
    

    then:

    mainform.consoleBinding.DataSource = consoleSource.EventList;
    

    Also you don’t need this line:

    mainform.consoleBinding.DataSource = typeof(LogEvent);
    

    Basically this is all there is to it:

    events = new Collection<LogEvent>(); // or List<> if you want
    bindingSource.DataSource = events;
    dataGridView.DataSource = bindingSource;
    

    then add items like:

    events.Add(event);
    bindingSource.ResetBindings(false);
    

    or simply :

    bindingSource.Add(event);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Somehow, Tortoise against Subversion can't seem to figure out that the source is not
hello fellow java developers. I'm having a very strange issue. I'm trying to read
I have Eclipse Galileo (for Java EE Developers) installed, and I'm now trying to
i'm trying to include a maven java project into my android project. the maven
I'm trying out the Eclipse Java 'Export Runnable JAR file. It creates a single
I'm a .NET Developer trying my hand at Java. My current project has a
I am a newbie Scala developer trying to figure out how to design a
I am trying to install subversive and checkstyle onto Eclipse IDE for Java Developers
For .net developers usercontrols are vital. I am trying to develop a java swing
I'm a long time C++/Java developer trying to get into Python and am looking

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.