Tuesday, 27 August 2013

List directory files in a DataGrid

List directory files in a DataGrid

I have searched many topics and can't find an answer on using the WPF
DataGrid to list file name contents from a directory. I am able to output
the contents in a ListBox but have no idea how to add items to a Column in
DataGrid.
This works for a ListBox
string path = "C:";
object[] AllFiles = new DirectoryInfo(path).GetFiles().ToArray();
foreach (object o in AllFiles)
{
listbox.Items.Add(o.ToString());
}
How can I do the same with a DataGrid? Or atleast place strings from an
array into a DataGrid Column?

No comments:

Post a Comment