Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim info As New DirectoryInfo("C:\Users\JuniorT\Desktop\SampleDirectoryScanner")
Dim files As FileInfo()
files = info.GetFiles()
dgFile.Rows.Add(files.Length)
For i = 0 To files.Length - 1
Dim driveLetter As String = files(i).FullName.ToCharArray(0, 3)
dgFile.Rows(i).Cells(0).Value = driveLetter
dgFile.Rows(i).Cells(1).Value = files(i).Name
dgFile.Rows(i).Cells(2).Value = files(i).FullName
Next i
End Sub
End Class
复制代码
dfFile, 是 我的DataGridView作者: Autistic紅毛丹 时间: 2010-9-1 02:32 AM
我的出现error-----------
Rows cannot be programmatically added to the DataGridView's rows collection when the control is data-bound.
到底是为什么吖T.T作者: 宅男-兜着走 时间: 2010-9-1 02:50 AM
我的出现error-----------
Rows cannot be programmatically added to the DataGridView's rows collectio ...
Autistic紅毛丹 发表于 2010-9-1 02:32 AM
啊哈哈哈哈哈哈!!!
因为你用资料绑定的关系。
你是存进DataBase过的吧??
你有两种做法:
1. 资料库里面存 Driver Letter, Full Path, File Name 这些, 意思就是做了计算后, 一次过Insert 进去。
2. 存FullPath, 然后再来执行计算。作者: Autistic紅毛丹 时间: 2010-9-1 07:06 AM 本帖最后由 Autistic紅毛丹 于 2010-9-1 09:28 AM 编辑