Solved

vb.net and wmi process list query

Posted on 2014-11-01
4
404 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 34

Expert Comment

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

-saige-
0
 
LVL 34

Accepted Solution

by:
it_saige earned 500 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

Create CentOS 7 Newton Packstack Running Keystone

A bug was filed against RDO for the installation of Keystone v3. This guide is designed to walk you through the configuration for using Keystone v3 with Packstack. You will accomplish this using various repos and the Answers file.

Question has a verified solution.

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

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

635 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