I’m working on a desktop application in C# that reads a directory and displays in a DataGridView the directory entries of the PDFs found in that directory, like a File Explorer that only shows PDFs. The user will need to be able to rearrange the order of the files in the DataGridView by dragging and dropping (single row select, not multi). This reordering is not 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. After this, the user has the application process the PDFs in the rearranged order by looping through the rows of the DataGridView.
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 can create an array of objects, one object per column, and store the array 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. Can you give a brief rundown of 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?