user3001471
user3001471

Reputation: 37

Re-ordering Columns in Datagridview VB.net

I'm trying to swap columns 1&2 with columns 6&7 for display. This is the code I have but it doesn't work?

dgvListings.Columns(1).DisplayIndex = 6
dgvListings.Columns(2).DisplayIndex = 7
dgvListings.Columns(6).DisplayIndex = 1
dgvListings.Columns(7).DisplayIndex = 2

Upvotes: 0

Views: 4805

Answers (1)

Indranil.Bharambe
Indranil.Bharambe

Reputation: 1498

You need to set the property

dgvListings.AutoGenerateColumns = false;

prior to setting the column order.

Upvotes: 1

Related Questions