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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T20:49:48+00:00 2026-06-01T20:49:48+00:00

I have trouble getting info about a selected item in a listbox in windows

  • 0

I have trouble getting info about a selected item in a listbox in windows forms. I have a collection populated with “Persons” that have a “PersonID” and a “FirstName”. I don´t want the “PersonID ” to be showned in the list, only the persons name – but when i select a person from the list, how do i know what the ID is?

    public int PersonID { get; set; }
    public string FirstName { get; set; }

I know i can compare the “FirstName ” in the collection but that´s not good enough if the name is the same as another persons.
How do i solve this?

  • 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-01T20:49:51+00:00Added an answer on June 1, 2026 at 8:49 pm

    You can either use the DisplayMember / ValueMember properties of the ListBox control, or you can also override the ToString() method of your Person class to return the name of the person.

    In this case, only the name of the person will be displayed, but calling ListBox.SelectedItem() will still return the complete Person instance.

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

Sidebar

Related Questions

It seems that I have more trouble getting standard Unix things to run on
Im having some trouble getting the syntax right. I have a movie clip that
I have a rails app that has asynchronous processing, and I'm having trouble getting
I have trouble getting a custom ObjectDataSource for an asp:ListView control to work. I
This seemed like it should be easy, but I have had trouble getting it
Hi I am having trouble getting an embedded js file to work. I have
I am having trouble getting my modal view controllers to display properly. I have
I am having trouble getting a Django ORM query to work correctly. I have
I have a fairly simple maven-ized Java project, but am having trouble getting my
I'm having trouble finding/getting any logging output from a web service. I have a

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.