Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

ListView

Posted on 2009-07-10
3
Medium Priority
?
307 Views
Last Modified: 2012-05-07
I have added a ListView to my form.

I have a class Called Contact with name, lastname and phone nr.
How do I add all this to my listview?
All my contacts is in a List<Contact>

And....finally is it possible to add a dropdownlist in a listview? For example if my phone nr will be added in alist so you can have more than one phone nr?
0
Comment
Question by:Mickeys
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 15

Accepted Solution

by:
angus_young_acdc earned 2000 total points
ID: 24824426
The follow snippet will add each of your contacts from the list to your ListView.  As for a dropdownlist, you would need to google for a custom listview control.
foreach (Contact contact in contacts)
            {
                ListViewItem subItem = listView1.Items.Add(contact.Name);
                subItem.SubItems.Add(contact.LastName);
                subItem.SubItems.Add(contact.PhoneNr);
            }

Open in new window

0
 
LVL 15

Expert Comment

by:angus_young_acdc
ID: 24824444
Oh should add to that, be sure have created the columns in your list view.
0
 

Author Comment

by:Mickeys
ID: 24829257
Right now they appear after each other like this

Mike Andersson        Peter Carlsson   .......

I want them to be each on one row like:
Mike Andersson
Peter Carlsson
......

and also....how do I add column name?
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question