Steve
asked on
Populating a datagrid from the filesystem.
I need to populate a datagrid with the files returned from any path the user provides. I can get this to work using a listbox, which that code is also provided below, but I can't get it to populate the datagrid. Can anyone help me with this??
The datagrid portion is at the bottom of the code block.
Public Sub btnImport_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnImport.Click
Dim Searcher As New FileSearcher("*.*")
Dim strFilePath As String
strFilePath = txtPath.Text
'***********Listbox Code*************
' Perform a single-directory search.
Searcher.Search(strFilePat h, False)
' Display results.
Dim File As FileInfo
For Each File In Searcher.Matches
lbFiles.Items.Add(File.Ful lName)
Next
' Perform a recursive directory search.
Searcher.Search(strFilePat h, True)
' Display results.
For Each File In Searcher.Matches
lbFiles.Items.Add(File.Ful lName)
Next
'*******End of Listbox Code***********
'***********Datagrid Code*************
dgFiles.DataSource = File.FullName
dgFiles.DataBindings.Add(F ile.FullNa me)
'*******End of Datagrid Code**********
lblCount.Text = lbFiles.Items.Count
End Sub
The datagrid portion is at the bottom of the code block.
Public Sub btnImport_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnImport.Click
Dim Searcher As New FileSearcher("*.*")
Dim strFilePath As String
strFilePath = txtPath.Text
'***********Listbox Code*************
' Perform a single-directory search.
Searcher.Search(strFilePat
' Display results.
Dim File As FileInfo
For Each File In Searcher.Matches
lbFiles.Items.Add(File.Ful
Next
' Perform a recursive directory search.
Searcher.Search(strFilePat
' Display results.
For Each File In Searcher.Matches
lbFiles.Items.Add(File.Ful
Next
'*******End of Listbox Code***********
'***********Datagrid Code*************
dgFiles.DataSource = File.FullName
dgFiles.DataBindings.Add(F
'*******End of Datagrid Code**********
lblCount.Text = lbFiles.Items.Count
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER