Plz HELP Convert DataGrid to TextBox

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Dec 2008
Posts: 1
Reputation: mujaqo is an unknown quantity at this point 
Solved Threads: 0
mujaqo mujaqo is offline Offline
Newbie Poster

Plz HELP Convert DataGrid to TextBox

 
0
  #1
Dec 16th, 2008
Hi,
I’m new to VB and I use the below code to collect local disk drive info, is there a way to store the collected information in a single text box instead of having tables and DataGridView.

  1.  
  2. Public Function getLogicalDriveStructure() As DataTable
  3. Dim dt As New DataTable
  4. dt.Columns.Add(New DataColumn("Description"))
  5. dt.Columns.Add(New DataColumn("DeviceID"))
  6. dt.Columns.Add(New DataColumn("FileSystem"))
  7. dt.Columns.Add(New DataColumn("FreeSpace"))
  8. dt.Columns.Add(New DataColumn("Name"))
  9. dt.Columns.Add(New DataColumn("Size"))
  10.  
  11. Return dt
  12. End Function
  13.  
  14.  
  15.  
  16. Public Sub addLogicalDrive(ByRef dt As DataTable, ByVal Description As String, ByVal DeviceID As String, ByVal FileSystem As String, ByVal FreeSpace As String, ByVal Name As String, ByVal Size As String)
  17. Dim dr As DataRow
  18. dr = dt.NewRow
  19. dr("Description") = Description
  20. dr("DeviceID") = DeviceID
  21. dr("FileSystem") = FileSystem
  22. dr("FreeSpace") = FreeSpace
  23. dr("Name") = Name
  24. dr("Size") = Size
  25. dt.Rows.Add(dr)
  26. End Sub
  27.  
  28.  
  29. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  30. Try
  31. Dim searcher As New Management.ManagementObjectSearcher( _
  32. "root\CIMV2", "SELECT * FROM Win32_LogicalDisk")
  33. Dim dt As DataTable = getLogicalDriveStructure()
  34. For Each queryObj As ManagementObject In searcher.Get()
  35. addLogicalDrive(dt, queryObj("Description"), queryObj("DeviceID"), queryObj("FileSystem"), Convert.ToString(queryObj("FreeSpace")), queryObj("Name"), Convert.ToString(queryObj("Size")))
  36. Next
  37. DataGridView1.DataSource = dt
  38.  
  39. Catch err As ManagementException
  40. MessageBox.Show("An error occurred while querying for WMI data: " & err.Message)
  41. End Try
  42.  
  43.  
  44. End Sub
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 25
Reputation: poguemahone is an unknown quantity at this point 
Solved Threads: 2
poguemahone's Avatar
poguemahone poguemahone is offline Offline
Light Poster

Re: Plz HELP Convert DataGrid to TextBox

 
0
  #2
Dec 27th, 2008
You could start off by using the System.IO namespace of the .NET Framework. What is the purpose of storing all that info in textbox? You could store some sort of a unique identifier as the value of the textbox and then when a user selects something from the textbox, showw the details of the drive[object] that they selected.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the VB.NET Forum
Thread Tools Search this Thread



Tag cloud for VB.NET
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC