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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T18:29:03+00:00 2026-05-11T18:29:03+00:00

I want a ListBox full of items. Although, each item should have a different

  • 0

I want a ListBox full of items. Although, each item should have a different value.
So when the user selects an item and presses a button, a method will be called which will use the value the select item has.

I don’t want to reveal the item values to the user.

EDIT: This is not for ASP.NET, it’s for a Windows Forms application. I just thought the HTML example would be easy to read.

I have the inspiration from HTML:

<form>
<input type="radio" name="sex" value="Value1" /> Male
<br />
<input type="radio" name="sex" value="Value2" /> Female
</form>

This also allows me to use different values than what the user sees.

  • 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-11T18:29:04+00:00Added an answer on May 11, 2026 at 6:29 pm

    You can choose what do display using the DisplayMember of the ListBox.

    List<SomeData> data = new List<SomeData>();
    data.Add(new SomeData() { Value = 1, Text= "Some Text"});
    data.Add(new SomeData() { Value = 2, Text = "Some Other Text"});
    listBox1.DisplayMember = "Text";
    listBox1.DataSource = data;
    

    When the user selects an item, you can read the value (or any other property) from the selected object:

    int value = (listBox1.SelectedItem as SomeData).Value;
    

    Update: note that DisplayMember works only with properties, not with fields, so you need to alter your class a bit:

    public class SomeData
    {
        public string Value { get; set; };
        public string Text { get; set; };
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to make a ListBox that arranges items horizontally. Each item should be
I have a listbox full of items for my order. I want to take
I have a ListBox with horizontal scrolling, and each item consists of a two
I want to popuate a listbox with objects of different types. I display the
I want to sort items in ListBox in aspx.net. I'm binding Datasource to my
I want to override the selection behavior of ListBox Items. We can traverse through
I want my ListBox to have columns, and one of those columns have to
I want the items inside ListBox to fill all allotted space. But they don't.
I am trying to have a listbox showing the friends a specific user has.
I want to disable listbox (not allow user to selected) but scrollable in Silverlight,

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.