|
-
Apr 23rd, 2007, 10:00 PM
#1
Thread Starter
Addicted Member
Populating a data grid
Hi everyone,
I am trying to populate my datagrid (name: GridLocalDisk) with data from a WMI query.
I have three columns within my data grid (Drive, diskSize, and Remaining)
How would I populate each "DeviceID" into the "Drive" column?
How would I populate each "Size" into the "diskSize" column?
How would I populate each "FreeSpace" into the "Remaining" column?
Below is my WMI code. I currently have the data outputting to a listbox (ListBox3).
Any help would be greatly appreciated.
Code:
Function SetBytes(ByVal Bytes) As String
SetBytes = Format(Bytes / 1024 / 1024 / 1024, "#0.00") & " GB"
End Function
Private Sub btnQueryMachine_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnQueryMachine.Click
Dim manScope As ManagementScope
Dim manPath As ManagementPath
Dim manClass As ManagementClass
Dim manObj As ManagementObject
Dim manObjCol As ManagementObjectCollection
Dim output As String = String.Empty
Dim RemoteMachineName As String
RemoteMachineName = "COMPUTERNAME"
Try
manPath = New ManagementPath("\\" & RemoteMachineName & "\root\CIMV2:Win32_LogicalDisk")
manScope = New ManagementScope(manPath)
'Since it is a remote system, you must provide proper credentials to access it
'manScope.Options.Username = "yourDomainName\administrator"
'manScope.Options.Password = "yourPassword"
manClass = New ManagementClass(manScope, manPath, Nothing)
manObjCol = manClass.GetInstances()
For Each manObj In manObjCol
If (manObj("Description").ToString) = "Local Fixed Disk" Then
ListBox3.Items.Add(manObj("DeviceID").ToString)
ListBox3.Items.Add(SetBytes(manObj("Size").ToString))
ListBox3.Items.Add(SetBytes(manObj("FreeSpace").ToString))
End If
Next
' MessageBox.Show(output)
Catch ex As Exception
' MessageBox.Show(ex.Message)
Finally
manPath = Nothing
manScope = Nothing
manClass = Nothing
manObjCol = Nothing
End Try
End Sub
-
Apr 24th, 2007, 06:00 AM
#2
Thread Starter
Addicted Member
Re: Populating a data grid
I have still been doing some research, but I can not figure out how to populate this data.... hmmmmmmmm
any suggestions?
-
Apr 24th, 2007, 06:35 AM
#3
Thread Starter
Addicted Member
Re: Populating a data grid
Is what I am doing even possible using a datagrid? If not, is there an equivalent item I can use and get the same desired end results?
-
Apr 24th, 2007, 06:45 AM
#4
Addicted Member
Re: Populating a data grid
MSDN on How To: Datagrid. Best I can do for ya GF.
Abrium
Asking the beginners questions so you don't have to!
If by chance hell actually froze over and I some how helped you... Please rate.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|