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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:36:31+00:00 2026-05-23T07:36:31+00:00

Hi coders I have yet another question involving data binding in winforms. I set

  • 0

Hi coders I have yet another question involving data binding in winforms. I set up a test applications where I have a bindinglist composed of structs called CustomerInfo. I have bound a listbox control to this list and spun a thread to add CustomerInfo items to the bindinglist.

namespace dataBindingSample {

public partial class Form1 : Form {

    public BindingList<CustomerInfo> stringList = new BindingList<CustomerInfo>();
    public Thread testThread;

    public Form1() {

        InitializeComponent();

        stringList.AllowNew = true;
        stringList.RaiseListChangedEvents = true;
        listBox1.DataSource = stringList;

        testThread = new Thread(new ThreadStart(hh_net_retask_request_func));
        testThread.Priority = ThreadPriority.Normal;

    }

    private void hh_net_retask_request_func() {

        int counter = 1;
        while (true) {


            CustomerInfo cust = new CustomerInfo();
            cust.Name = "Customer "+ counter.ToString();

            this.Invoke((MethodInvoker)delegate {

                stringList.Add(cust);

            });

            counter++;
            Thread.Sleep(1000);

        }

    }

    private void Form1_Load(object sender, EventArgs e) {
        testThread.Start();
    }

}

public struct CustomerInfo {

    public string Name {

        set {

            name = value;
        }

        get {
            return name;
        }

    }

    private string name;
  }
}

What I see in the list box is the name of the struct dataBindingSample.CustomerInfo as opposed to the property of the struct. I was under the impression that non complex binding took the first available property.

Please educate me as to what I am doing wrong.

Thanks,

  • 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-23T07:36:32+00:00Added an answer on May 23, 2026 at 7:36 am

    You’ll need to either add an override of ToString() to your CustomerInfo class that returns what you’d like displyed in your list box, or set listBox1.DisplayMemer = "Name" before setting the DataSource.

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

Sidebar

Related Questions

I think I have hit a coders block here. I am writing a game
I have a nested form which looks something like: <FORM METHOD=GET NAME=mainForm ACTION=<%=response.encodeURL(updateForm.jsp)%>> </FORM>
I am exploring the EnvDTE library, and building a form generator. I have successfully
I am trying to call some legacy C code using interop in C#. I
First off, I apologize if it's considered poor etiquette to cross-post on stackexchange sites,
I'm testing a web application with ruby 1.8.7 and WATiR and I'd like to
So I am attempting to learn how to code my first BST, and it
Currently I'm working on setting up a basic WebSockets script. I can get the
EDIT: running it through the gdb gives Program received signal SIGSEGV, Segmentation fault. 0x0000000000400e4c
I've been spending time to assimilate the methodologies behind writing testable code, and I

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.