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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:54:46+00:00 2026-05-25T06:54:46+00:00

Hope you guys can help me out once more before I go nuts. Iv’e

  • 0

Hope you guys can help me out once more before I go nuts.
Iv’e been searching ligh and low, here and on google.
Gone through MSDN back and forth, but to no avail… I just don’t understand what I’m doing wrong…

I have a form, where I have added a listview (without any changes to the default settings when it’s beeing dragged to the form).

After a day of fooling around, I got to simply trying an easy example since nothing I wanted to do would work. The example got to serve as some kind of “If this doesn’t work, then it’s time to ask for help!”…

This is the example;

ListViewItem item = new ListViewItem();
item.Text = "FirstItem";
item.SubItems.Add("A subitem");
item.SubItems.Add("A second subitem");
item.SubItems.Add("A third subitem");
listView1.Items.Add(item);

All that this example gives me, it “FirstItem”, nothing else…

My own version that I wanted to try, is the following:

I have a dictionary named “members”. it contains two two strings, “name” as Key, and “LastSeen” ad Value.

I’m trying the following:

if (GroupMembers.Count > 0)
{
    listView1.Items.Clear();
    key2name getname = new key2name();
    ListViewItem lvi = new ListViewItem("Name");
    ListViewItem lvi2 = new ListViewItem("Last seen");
    listView1.Columns.Add("Name", -2, HorizontalAlignment.Left);
    listView1.Columns.Add("LastSeen", -2, HorizontalAlignment.Left);
    foreach (KeyValuePair<string, string> member in GroupMembers)
    {
        lvi.SubItems.Add(member.Key);
        lvi2.SubItems.Add(member.Value);
    }
    listView1.Items.AddRange(new ListViewItem[] { lvi, lvi2 });
}

What I am trying to acomplish, is that my listview will show two columns, with the first column name with the text “Name”, and the second “Last seen”.
Under each of those columns, I want the content of my dictionary to show up.

Can someone please help me shed some light over this before I go completely nuts over this?
Thanks…

Although the answers were right, I still don’t get the utput I want, and I’m not sure of how to do it..

Now I do see the columns,
but I get this:

|  Name    | LastSeen   |
|Last seen | 2011-09-06 |
|Name      | Full Name  |

What I want is:

|  Name    | LastSeen   |
|FullName  | 2011-09-06 |
|FullName  | 2011-09-06 |
|FullName  | 2011-09-06 |

The dictionary curently contains 3 KeyValuePairs

  • 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-25T06:54:47+00:00Added an answer on May 25, 2026 at 6:54 am

    The example is right, you should put the listView in details mode and add the columns.

    Your code after that is wrong you should not create two list items lvi and lv2, just create only 1 inside the foreach, its text is the text of first column, add subitems to it and add the item to the listview inside the foreach.

    You will see the columns only when you have set the ListView in details mode.

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

Sidebar

Related Questions

After an extensive unsuccessful search I hope you guys can help me out here...
First time stackoverflow user but occasional lurker, hope you guys can help me out.
Hope you guys can help me out. I have information coming into a serial
I hope you guys can help me out. I'm using C# .Net 4.0 I
I am a newbie with hibernate I hope you guys can help me out
I'm really confused so I hope you guys can help me. I know how
I've run in to a problem I hope you guys can help me with.
I hope some of you guys can help me with this problem.... I have
Hi everybody I seem to be stuck and I hope you guys can help
i have a problem so hope you guys can help! I have a string

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.