diamondgeezer1974
Member
Hi.
Ok, I must be missing something really simple here.
I have a form with just a Datagridview on it
Why doesn't this work?
MyFileInfo is just a class that stores the Name, FullName and Length of the file..... I don't want all of the columns returned that GetFiles() normally kicks out.
If I did DataGridview1.Datasource = New DirectoryInfo("D:\").GetFiles then the datagridview shows all the results alright, but if I try and use MyFileInfo class as a DataSource the DataGridView doesn't show anything back, even though I can see that the DataSource does have values when debugging, it just doesn't show it in the DataGridView control.
Any ideas?
DG
Ok, I must be missing something really simple here.
I have a form with just a Datagridview on it
Why doesn't this work?
Imports System.IO Public Class Form1 Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load Dim filelist As New List(Of MyFileInfo) For Each fi As FileInfo In New DirectoryInfo("D:\").GetFiles Dim myfile As New MyFileInfo With {.Name = fi.Name, .FullName = fi.FullName, .Length = fi.Length} filelist.Add(myfile) Next DataGridView1.DataSource = filelist End Sub End Class Public Class MyFileInfo Public Name As String Public Length As Long Public FullName As String Public Sub New() End Sub Public Sub New(ByVal Name As String) Me.Name = Name End Sub End Class
MyFileInfo is just a class that stores the Name, FullName and Length of the file..... I don't want all of the columns returned that GetFiles() normally kicks out.
If I did DataGridview1.Datasource = New DirectoryInfo("D:\").GetFiles then the datagridview shows all the results alright, but if I try and use MyFileInfo class as a DataSource the DataGridView doesn't show anything back, even though I can see that the DataSource does have values when debugging, it just doesn't show it in the DataGridView control.
Any ideas?
DG
Last edited by a moderator: