private void DisplayFiles()
{
lstPhotos.Items.AddRange(files);
}
files is a List This gives this error:
cannot convert from 'System.Collections.Generic.List' to 'object[]'
Which makes sense. What should I do?
private void DisplayFiles()
{
lstPhotos.Items.AddRange(files);
}
files is a List This gives this error:
cannot convert from 'System.Collections.Generic.List' to 'object[]'
Which makes sense. What should I do?
Try this instead:
private void DisplayFiles()
{
lstPhotos.Items.AddRange(files.ToArray<object>);
}
private void DisplayFiles()
{
lstPhotos.Items.AddRange(files.ToArray());
}
That should work. You could also bind the list to the listbox which is the preferred way of doing it in WPF and Windows Forms.
lstPhotos.DataSource = files; // Windows Forms
lstPhotos.ItemsSource = files; // WPF