2 Replies - 387 Views - Last Post: 01 June 2011 - 09:48 PM Rate Topic: -----

#1 cfsharp  Icon User is offline

  • New D.I.C Head

Reputation: 3
  • View blog
  • Posts: 10
  • Joined: 29-May 11

Adding SubItems to ItemLists

Posted 01 June 2011 - 09:15 PM

Hi, i'm trying to make a process list for a task killer i'm working on. I have 2 column's, Process Name, and Process ID. I need to add the ID to the second column, but i can't seem to figure out how. Here is the code i'm trying right now.

        private void Processes_Load(object sender, EventArgs e)
        {
            foreach (Process process in Process.GetProcesses())
            {
                Count++;
                listView1.Items.Add(process.ProcessName);
                //listView1.Items(Count).SubItems.Add(process.Id);
                
            }
        }


Hopefully you can see what i'm trying to do there, oh yeah int Count is declared way up at the top of the source.

Is This A Good Question/Topic? 0
  • +

Replies To: Adding SubItems to ItemLists

#2 Jeff H  Icon User is offline

  • D.I.C Regular

Reputation: 112
  • View blog
  • Posts: 308
  • Joined: 30-January 11

Re: Adding SubItems to ItemLists

Posted 01 June 2011 - 09:28 PM

Have you tried creating a new ListViewItem then adding it to the ListView?

Something like


            ListViewItem lvi = new ListViewItem(process.ProcessName);
            lvi.SubItems.Add(process.Id);
            listView1.Items.Add(lvi);


Was This Post Helpful? 1
  • +
  • -

#3 cfsharp  Icon User is offline

  • New D.I.C Head

Reputation: 3
  • View blog
  • Posts: 10
  • Joined: 29-May 11

Re: Adding SubItems to ItemLists

Posted 01 June 2011 - 09:48 PM

View PostJeff H, on 01 June 2011 - 09:28 PM, said:

Have you tried creating a new ListViewItem then adding it to the ListView?

Something like


            ListViewItem lvi = new ListViewItem(process.ProcessName);
            lvi.SubItems.Add(process.Id);
            listView1.Items.Add(lvi);



Thanks! That's pretty funny because i read some documentation, and figured it out literately seconds before you replied. Thanks though!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1