Toby Person
Toby Person

Reputation: 211

TaskManager-Styled Listbox in C#

How would I get a ListBox of the type that is in the Processes tab of the Windows Task Manager in C#?

Is there a reference I need to add, a control or something else?

I've been looking around on Google for hours and I can't find anything.

Upvotes: 0

Views: 486

Answers (4)

Derek
Derek

Reputation: 8628

Use the ListView Object, below is a real simple example :-

 private void Form1_Load(object sender, EventArgs e)
        {
            listView1.Columns.Add("Image Name");
            listView1.Columns.Add("Username");
            listView1.Columns.Add("CPU");
            listView1.Columns.Add("Memory");

            listView1.View = View.Details;

        }

Upvotes: 0

HaemEternal
HaemEternal

Reputation: 2269

To get the running processes and add them to your ListView, you could do something like:

foreach (Process process in Process.GetProcesses())
{
    string[] itemArray = {process.ProcessName};
    item = new ListViewItem(itemArray) {BackColor = Color.White};
    yourListView.Items.Add(item);               
}

Upvotes: 1

Caster Troy
Caster Troy

Reputation: 2866

enter image description here

Something like that? Then you want a ListView control with the Display Property set to Details. You can then edit the columns pro grammatically very easily or by means of a collection editor just find the Columns property and click the ellipsis button.

enter image description here

Upvotes: 2

ken2k
ken2k

Reputation: 49013

If you're using winforms for the UI, then it's a ListView control.

Upvotes: 0

Related Questions