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 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

Related Questions

I am writing a WinForms app which will execute some web UI tests written
I'm writing a system tray Winforms app which does some very important cleanup on
I'm writing a WinForms app which has two modes: console or GUI. Three projects
I'm writing an winforms app that needs to set internet explorer's proxy settings and
I have some code like this in a winforms app I was writing to
I'm writing an application that can be started either as a standard WinForms app
Writing a routine WinForms app that references a few custom libraries written by myself.
I'm writing a .NET 3.5 application (WinForms) which uses classes from an external DLL
I have a Winforms app which runs under a standard user account (i.e. user
When I have a WinForms app that needs to do some heavy lifting in

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.