?
Solved

ListView

Posted on 2009-07-10
3
Medium Priority
?
305 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

762 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