Was struggling with a very weird bug this weekend. When databinding to a DataGridView the column order was changed.

Googling about the problem let me to this forum thread. Apparently it is a known bug with the DataGridView, and it is fixed by setting the AutoGenerateColumns property to false before databinding.

  1. dgvLines.AutoGenerateColumns = False
  2. dgvLines.DataSource = New BindingList(Of PaymentLedgerItem)(CurrentLedger.Items)

Normally I would set the AutoGenerateColumns to false when databinding, but it wasn’t necessary for this implementation – so I thought…