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

The Archive Base Latest Questions

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

I am writing a winforms app in which a user selects an item from

  • 0

I am writing a winforms app in which a user selects an item from a listbox and edits some data that forms part of an associated object. The edits are then applied from the object list to an underlying file.

In ASP.Net assigning a different system value to a list item than the display text the user sees is trivial. In a winforms app you have to set the ‘Displaymember’ and the ‘Valuemember’ of each item in a slightly more complicated (and not oft related on the internet) process.

This I have done. In debug mode I have confirmed that every item now has a value which is the display member (a ‘friendly’ string that the user sees) and a key, the valuemember, which holds the key to a hashtable object where the data to be updated exists.

So when a user picks a string to edit the program should pass the ‘key’ to the hashtable, yank out the object and allow editing to take place upon it.

The catch?

I can’t see any obvious way of telling the program to look at the item’s valuemember. I naively expected it to populate the list box’s ‘SelectedValue’ property, but that would be too simple by far. So how the hell do I get to the list item value?

  • 1 1 Answer
  • 1 View
  • 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. 2026-05-11T07:36:36+00:00Added an answer on May 11, 2026 at 7:36 am

    Okay so the answer came as a result of Andy’s answer, hence my upvoting that answer.

    But when I created a little class and tried to cast the listitem into that class the program threw an exception.

    Revealingly the exception told me that the program could not cast a DictionaryEntry into a class of the type I had defined.

    So I deleted the proxy class and reframed the request thus:

    DictionaryEntry de = (DictionaryEntry)listbox.SelectedItem;
    string htKey = de.Key.ToString();

    And it’s all good.

    Bizarrely simple answer in the end. Thanks for the hint Andy.

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

Sidebar

Ask A Question

Stats

  • Questions 81k
  • Answers 81k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I was able to solve my dilemma by getting the… May 11, 2026 at 4:31 pm
  • Editorial Team
    Editorial Team added an answer You can wrap the function pointer in a struct: struct… May 11, 2026 at 4:31 pm
  • Editorial Team
    Editorial Team added an answer Working on the idea from Oscar of using a ListCellRenderer,… May 11, 2026 at 4:31 pm

Related Questions

I'm using a winforms webbrowser control to display some content in a windows forms
I have some code like this in a winforms app I was writing to
I am a solo dev building a WinForm App, C# & .Net 3.5, in
I am doing an Financial Winforms application and am having some trouble with the

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.