@JamieVJohnson2 / @pball / @NachoShaw / @matt_jlt ,
I was able to get the code working using only a DataGridView and a workaround to resolve a sorting issue.
To expand my knowledge, I rewrote portions of the code to use a DataTable, DataView, and a DataGridView.
I have encountered challenges that involve cell BackColor and a column named, FullFileName. I store the reference document name in this column, but don't want to display it.
Here is a summary of the code:
- Dim a DataTable (myTable), a DataView (myView), and a DataGridView (myDGV)
- Build myTable with columns (BuildBaseTable)
- Set myView based on myTable.DefaultView [line 159]
- Sort myView by Flat Pattern, Component [line 161]
- Populate the DataTable with sheet metal component info (RetrieveReferences)
- Format myDGV [line 169]
- Add myDGV and button controls to myForm
- Display the Form (myForm)
- Wait for button picks
Challenge 1:
Since switching to a DataGridView which is linked to a DataView, which is linked to a DataTable, I cannot change the BackColor of certain cells. I want cells containing "No" to be BackColor = Yellow
See line 76 in RetrieveReferences : index out of range error when line is uncommented

Can you change cell BackColor before the DataGridView is displayed in the Form? Although disabled in the code, I can change BackColor if the Form and DataGridView when they are already displayed or.
Challenge 2:
If I display the FullFileName column, then user can select rows to open those selected documents (Open Selected button).
If I hide the FullFileName column, then errors occur when user tries to open the selected documents.
See lines 238 - 239 for the various ways I have tried to hide the FullFileName column.
ERRORS:
System.InvalidCastException: Unable to cast object of type 'System.Data.DataView' to type 'System.Data.DataTable'.
at FormClass.OpenSelected()
or
System.ArgumentException: Column named FullFileName cannot be found.
Parameter name: columnName
I have attached the code, since I thought it was too large to include in the message body.
To test, use any assembly with sheet metal components. For example, the Inventor Sample model named Personal Computer.iam.
Thank you for your time and attention. I look forward to your replies.
Kind regards,
Jerry
-----------------------------------------------------------------------------------------
CAD Administrator
Using AutoCAD & Inventor 2025
Autodesk Certified Instructor
Autodesk Inventor 2020 Certified Professional
Autodesk AutoCAD 2017 Certified Professional