I'm working on an application in C# that reads a directory and displays the directory entries for the PDFs found in that directory in a DataGridView, like a File Explorer that only shows PDFs. The user will need to be able to rearrange the order of the files by dragging and dropping the files (single row select, not multi). This reordering only happens in the DataGridView (nothing is written to disk), and is completely arbitrary, not by date or file name or anything like that. This is why the user reorders the files by dragging and dropping.
I had originally used a DataSet with a DataTable to store the directory contents. This DataTable is bound to the DataGridView with a BindingSource. I used this approach because it let me do a lot in the Visual Studio Designer. However, you can't insert and remove elements from a BindingSource if its bound to a DataTable. You would have to do the inserting and removing at the DataTable, but there's no way to insert a row at a specific location in a DataTable, so basically, I need a different kind of data source for my DVG.
Although Lists are not multicolumn, I know you create an array of objects, one per column, and store the array of objects as a List entry. I know you could also use a Class or a Dictionary. But I don't know the pros and cons of using each.
What about not using an in-memory structure but instead use the DVG in unbound mode, programmatically adding the rows as each directory entry is read? Once the files are ordered as the user desires, whatever processing is done to them will be done with a loop that cycles through the DGV rows, not the rows in the DataSource. Everything I read encourages to use data sources with their DGVs, but is this a use case that calls for unbound mode?
===
Moderators: There are no entries for C#, DataGridView, Windows Forms, or anything like that in these new forums.