Taryn
Taryn

Reputation: 247620

Arrange Columns in a DataGridView

I have a datagridview that is populated by a stored proc. Typically I would reorder the columns using the 'Edit Columns' dialog but this datagridview is being used to display data from different sources so I can't do that.

I have figured out how to rename the Headers and make certain columns Frozen but how do I change the display order on them?

Upvotes: 15

Views: 10987

Answers (3)

Mohamed AL-Hlwany
Mohamed AL-Hlwany

Reputation: 17

 grid.AllowUserToOrderColumns = true;

Upvotes: -1

Paolo Falabella
Paolo Falabella

Reputation: 25834

With the DisplayIndex property

myGridView.Columns["myFirstCol"].DisplayIndex = 0;
myGridView.Columns["mySecondCol"].DisplayIndex = 1;

Upvotes: 22

Bala R
Bala R

Reputation: 108937

Can you set the DisplayIndex for the columns?

Upvotes: 2

Related Questions