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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T06:28:37+00:00 2026-06-05T06:28:37+00:00

I have a listbox that i want to populate with contactpersoon objects that i

  • 0

I have a listbox that i want to populate with contactpersoon objects that i created.
The user completes a little form with a few textfields and when the user presses the ok button the contactpersoon object will be created.

The problem is now that i want to add the name property of the contactpersoon object to the listbox as an item. but when i want to delete it from the listbox i want to delete it by the id property of the object not the name property…

Can anyone help me with this. I tried using dictonaries but i didn’t get them to work properly.

Can anyone please advise/help me with this?

Thank you very much..

BTW Iam sorry for my bad englisch :p

  • 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-05T06:28:39+00:00Added an answer on June 5, 2026 at 6:28 am

    You need to override the ToString method in the ContactPerson class. For instance:

    public class ContactPerson
    {
        public string Name;
        public string Id;
    
        public override string ToString()
        {
            return Name;
        }
    }
    

    Then, you can add the actual ContactPerson objects to your list box. For instance:

    listbox.Items.Add(contactPerson);
    

    Then, when you delete, you can loop through each item in the list and read any of the properties of the ContactPerson object, such as:

    foreach(object item in listbox.Items)
    {
        if((ContactPerson)item.Id == ...)
        {
            // do work
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a ListBox that is bound to a list of Persons. I want
I have an Expander that I want to have a ListBox in. When the
I have a listbox where I want to copy and paste items within that
Is that even possible? I have two ObservableCollections. I want to bind and populate
I have a ListBox on a Windows Form that is populated during the Form_Load
I have a listbox on my xaml form that I bound to a List(Of
I want to have a Listbox that each time that an entry is chosen,
I have a ListBox that initially displays with the first item selected. I want
I have a listbox on my form that looks like this: <ListBox Name=lbResults SelectionChanged=lbResults_SelectionChanged/>
I created this User Control: I added that User Control to the main Form

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.