Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

vb.net and wmi process list query

Posted on 2014-11-01
4
Medium Priority
?
454 Views
Last Modified: 2014-11-01
I use the below code to return processes to a listview, i am trying to use a group header and no matter what i do it wont show up:

What am i doing wrong?

For Each managementObject As ManagementObject In (New ManagementObjectSearcher(theScope, objectQuery)).[Get]()
                Dim item As ListViewItem = ListView2.Items.Add(managementObject("ProcessId").ToString())
                item.SubItems.Add(managementObject("Name").ToString())
                item.Group = ListView2.Groups("Process List")
                'ListView2.Items.Add(item)
            Next

Open in new window

0
Comment
Question by:derek7467
  • 2
  • 2
4 Comments
 
LVL 35

Expert Comment

by:it_saige
ID: 40417310
What does not show up, the items or the group header?

-saige-
0
 
LVL 35

Accepted Solution

by:
it_saige earned 2000 total points
ID: 40417321
Here is an example:
Imports System
Imports System.Management

Public Class Form1
	Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
		Try
			Dim scope As New ManagementScope("root\CIMV2")
			Dim query As New ObjectQuery("Select * from Win32_Process")
			Dim item As ListViewItem = Nothing
			ListView1.Groups.Add(New ListViewGroup("Processes", "Process List"))
			For Each managementObject As ManagementObject In (New ManagementObjectSearcher(scope, query)).[Get]()
				item = New ListViewItem(managementObject("ProcessId").ToString())
				item.SubItems.Add(managementObject("Name").ToString())
				item.Group = ListView1.Groups("Processes")
				If Not item Is Nothing Then
					ListView1.Items.Add(item)
				End If
				item = Nothing
			Next
			ListView1.ShowGroups = True
		Catch ex As Exception
			MsgBox(ex.ToString)
		End Try
	End Sub
End Class

Open in new window


Produces the following output:Capture.JPG
-saige-
0
 

Author Comment

by:derek7467
ID: 40417364
Group header is missing I'll try your example. Thanks!
0
 

Author Closing Comment

by:derek7467
ID: 40417403
that worked, thanks!
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

876 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question