Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

vb.net and wmi process list query

Posted on 2014-11-01
4
Medium Priority
?
430 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 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

Use Filtering Commands to Process Files in Linux

Learn how to manipulate data with the help of various filtering commands such as `cat`, `fmt`, `pr`, and others in Linux.

Question has a verified solution.

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

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

715 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