list view items
-
Hello..i used a listview to view the current processes in my Computer..but when i tryed to make any operations on these processes i couldn't ..i donnno how to convert the list items into objects of other class to perform these operations (im my case the System.diagnostics.process class) here's my code : private void Form1_Load(object sender, System.EventArgs e) { Process[]MyProcArray=Process.GetProcesses (); foreach (Process MyProc in MyProcArray) {this.ProcessesList .Items .Add (MyProc.ProcessName ); } :confused:
-
Hello..i used a listview to view the current processes in my Computer..but when i tryed to make any operations on these processes i couldn't ..i donnno how to convert the list items into objects of other class to perform these operations (im my case the System.diagnostics.process class) here's my code : private void Form1_Load(object sender, System.EventArgs e) { Process[]MyProcArray=Process.GetProcesses (); foreach (Process MyProc in MyProcArray) {this.ProcessesList .Items .Add (MyProc.ProcessName ); } :confused:
The problem you are seeing is because you are only adding the string which represents the process name to the list view, instead you need to add the Process object itself.
private void Form1_Load(object sender, System.EventArgs e)
{
Process[] MyProcArray = Process.GetProcesses();foreach (Process MyProc in MyProcArray)
{
ProcessesList.Items.Add(MyProc);
}
}HTH, James Simplicity Rules!