Q:

Reordering columns in DataGridView then reading DisplayIndex with hidden columns

I have a DataGridView containing some columns - some added automatically and some added when a user performs a certain action. Some of the auto-generated columns are not visible, and the visible columns are frozen and read-only. From the user-added columns that are visible, a user can re-order these, and I use the order of these columns for something else later in my code.
The auto-generated columns are of the custom type DataGridViewUnincludedMetadataColumn and the user-generated columns are normal DataGridViewColumns.
The problem: 
I am trying to get a DataGridViewColumn[] (called orderedColumnList) which is just the user-generated, visible columns. 
I use this code to count the number of auto-generated, visible columns:
int unincludedVisibleColumnCount = 0;
foreach (var unincludedCol in dataGridView_Metadata.Columns.OfType<DataGridViewUnincludedMetadataColumn>())
{
    if (unincludedCol.Visible)
    {
        unincludedVisibleColumnCount++;
    }
}

I use this code to get my orderedColumnList:
foreach (DataGridViewColumn col in dataGridView_Metadata.Columns)
{
    if (col.GetType() != typeof(DataGridViewUnincludedMetadataColumn))
    {
        //if the column is going to be visible
        //add the column to the orderedcolumnlist 

        orderedColumnList[col.DisplayIndex - unincludedVisibleColumnCount] = col;

    }
}

The problem is that the DisplayIndex doesn't seem to match up with the actual index of where each column is being displayed. 
In my tests I'm getting this:
Index | DisplayIndex | Where the column actually is in the display
  0   |       0      |        0
  1   |       1      |        1
  2   |       4      |    n/a - Visible == false
  3   |       6*     |        5*
  4   |       3      |        3
  5   |       2      |        2
  6   |       5*     |        4*

Initially I thought it was just the last column that was off but then I tested by adding another user-generated column and it made the last two columns off by one, so I'm confused as to what the pattern here might be. 
Why are the starred values different, and how can I check for this in my code? 

A:

I have now figured this out thanks to @stuartd's comment, code is below. This uses the GetFirstColumn() and GetNextColumn() methods on the DataGridViewColumnCollection object with DataGridViewElementStates.Visible.
List<DataGridViewColumn> orderedColumnList = new List<DataGridViewColumn>();

DataGridViewColumn firstCol = dataGridView_Metadata.Columns.GetFirstColumn(DataGridViewElementStates.Visible);

DataGridViewColumn nextCol = dataGridView_Metadata.Columns.GetNextColumn(firstCol, DataGridViewElementStates.Visible, DataGridViewElementStates.None);
while (nextCol != null)
{
    if (nextCol.GetType() != typeof(DataGridViewUnincludedMetadataColumn))
    {
        orderedColumnList.Add(nextCol);                        
    }
    nextCol = dataGridView_Metadata.Columns.GetNextColumn(nextCol, DataGridViewElementStates.Visible, DataGridViewElementStates.None);
}

