Click here to Skip to main content
15,996,848 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a couple questions about this start..

tbLive is a text box with a path in it.
bTest is a button

Does it need MyBase.Load? I had a DataSet but I only need one table so I removed it.

How do I reference the table to get a column to a listbox?

It's all very confusing, I see the .find command but I don't see how you would use it. I think I need to set a primary key...

Should I use a multi-column listbox? All I need to do is have one list where I can program some items to show in another list... the items are folders that can be copied or moved or 'hidden' from the list.


VB
Imports System.IO
Imports System.Data

Private Sub Test_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

  DT = New DataTable("DTA")
  DT.Columns.Add("Folder", GetType(String))
  DT.Columns.Add("Show", GetType(String))

  Dim id As Integer
  For id = 1 To 2
    DT.Rows.Add(New Object() {id, String.Format("abc", id)})
  Next id

  DT.AcceptChanges()

End Sub

Private Sub bTest_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bTest.Click

    Dim di As New DirectoryInfo(tbLive.Text)
    Dim diArr As DirectoryInfo() = di.GetDirectories()
    Dim dri As DirectoryInfo
    For Each dri In diArr
        DT.Rows.Add(New Object() {dri.Name, ""})
    Next (dri)
    Dim i As Integer

    For i = 0 To DT.Rows.Count - 1
        lbLive.Items.Add(DT.Rows(i))  'this needs to specify the column...
    Next

End Sub
Posted

1 solution

As soon as I posted and swept up whats left of my hair off the floor I found one answer at http://www.dotnetspark.com/tutorial/13-43-edit-row-datatable.aspx[^]

lbLive.Items.Add(DT.Rows(i)("Folder"))

So the loop in question and the end should be this:
VB
For i = 0 To DT.Rows.Count - 1
  lbLive.Items.Add(DT.Rows(i)("Folder"))
Next


Still looking for a better way to find than looping the whole list...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900