Reputation: 211
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
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
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
Reputation: 2866
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.
Upvotes: 2