There may well be, or at least there should be a simpler solution than I will show here, but after struggling with this same issue the other day, I found that the following will at least work.
When searching the help index in VB.Net it indicates that you should use the "RemoveAt" method of the "GridColumnStylesCollection" object. Personally, I could never get this to work. Also, I could never find the "DataGridColumn.Visible" option. (I think this was a Visual Basic 6.0 feature that did not make the transition. Not sure, but that is my suspicion.)
Anyway, I was able to accomplish my objective (of having a hidden column from which I could still obtain data) by doing the following:
1. Programmatically build the datatable which will create the columns for my datagrid. I chose to declare a private modular variable of "_dtMyTable". (You can accomplish this same objective in a couple of ways.) I'll use your example for clarity which you may be able to copy and paste to get you started.
Private _dtMyTable as New DataTable(TableName)
Private Sub BuildMyTable()
'this procedure will build a temporary datatable
With _dtMyTable.Columns
.Add("Entity_ID", Type.GetType("System.Integer")).ColumnMapping = MappingType.Hidden '(Note: This will hide your column from view but it will still be accessible from the dataview that we will create later)
.Add("Date Of Order", Type.GetType("System.DateTime"))
.Add("Name", Type.GetType("System.String"))
.Add("Phone #", Type.GetType("System.String"))
.Add("Address", Type.GetType("System.String"))
End With
End Sub
Now you need to fill the blank table with data from your dataset(assuming here that you have already performed the necessary DataAdapter.Fill(MyDataSet,"TableName")procedure.)
Private Sub LoadMyTable()
Dim dr As DataRow
Dim dr2 As DataRow
'this procedure will add the rows to the temp table
'Check to make sure that the table has been built
If _dtMyTable.Columns.Count = 0 Then
Call BuildMyTable()
End If
'This example assumes (I know I shouldn't do that, but...)that the column names in your database / dataset are the same as the column names of the table we just created.
For Each dr2 In MyDataSet.Tables(0).Rows
dr = _dtMyTable.NewRow
dr("Entity_ID") = dr2("Entity_ID")
dr("Name") = dr2("Name")
dr("Phone #") = dr2("Phone #")
dr("Address") = dr2("Address")
_dtMyTable.Rows.Add(dr)
Next
'now bind a private dataview to the filled table
(Remember you must have created the private Dataview "dvMyDataView" previously, either in design view or programmatically)
dvMyDataView.Table = _dtMyTable '(Note: If you have assigned this value in design view it will be overridden here.)
dgMyDataGrid.DataSource = _dvMyDataView
End Sub
Now, when you want to retrieve that data, you must retrieve it from _dvMyDataView and not from the DataGrid. The DataView will still hold all of the data, it is just not visible in the datagrid.
I know this is a long way around getting this, so seemingly simple task accomplished, but it is the only way that I could get this to work for me. If there is a better / simpler solution out there, please let me know as I will be needing to use this in several instances in my current project.