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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T05:28:24+00:00 2026-06-09T05:28:24+00:00

I have a list view with two columns- name and number. I want to

  • 0

I have a list view with two columns- name and number. I want to read all these items and assign name to a combo box display member and number to value member. I have tried thinking the approach to follow but couldn’t help myself. This is what I have tried. How should I proceed?

    public class numbers
    {
        public string name;
        public string number;
    }
    public class names : List<numbers>
    { 

    }
    names cname = new names();

    public void addcontacts()
    {
        foreach(ListView lv in bufferedListView1)
        {
         //No idea how to proceed
  • 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-09T05:28:26+00:00Added an answer on June 9, 2026 at 5:28 am

    First you set your own type:

    public class myContact
    {
        public string Name { get; set; }
        public string Number { get; set; }
    
        public myContact(string name, string number)
        {
            this.Name = name;
            this.Number = number;
        }
    
        public override string ToString()
        {
            return Name;
        }
    }
    

    Then you transfer all items from the listview to the combobox like this:

    foreach (ListViewItem item in listView1.Items)
    {
        comboBox1.Items.Add(new myContact(item.Text, item.SubItems[0].Text));
    }
    

    This example assumes, that each listviewitem holds the name and that its first child holds the number.

    When you add objects to the combobox, C# will use the objects’ ToString() method to create something that you can actually see when the program is running. You override the default ToString() method with your own and only return the name. If you want to use the selection from the combobox you just cast the selectedItem back to myContact and can access the number there. Welcome to OOP 🙂

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

Sidebar

Related Questions

Ho I have two list view on a frame layout. I want one overlay
I have made a list view containing two childs. Now i am trying to
I have implemented a list view. Each item in my list view has two
I have a ListView that has two columns, one for a zone name and
I have a simple parent/child type view with two columns: MYID and MYPARENTID .
Hi I have a WebGrid with two columns: 1-Name 2-Action binded to another controller
I have a category table with two columns category_id and name . I have
I have these two models: class Application_Model_List extends Zend_Db_Table_Abstract { protected $_name = 'list';
I have ListView that uses a GridView to display several columns of data. Two
I have a listview with several items that are created dynamically, each has two

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.