943,812 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Unsolved
  • Views: 1186
  • VB.NET RSS
Dec 16th, 2008
0

Plz HELP Convert DataGrid to TextBox

Expand Post »
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.

VB.NET Syntax (Toggle Plain Text)
  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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
mujaqo is offline Offline
1 posts
since Dec 2008
Dec 27th, 2008
0

Re: Plz HELP Convert DataGrid to TextBox

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.
Reputation Points: 13
Solved Threads: 2
Light Poster
poguemahone is offline Offline
25 posts
since Aug 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: how to prepare a document
Next Thread in VB.NET Forum Timeline: how i make table in visual studio by using vb.net





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC