Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 781
Taryn Avatar asked Mar 02 '11 13:03

Taryn


People also ask

How to arrange column in DataGridView c#?

When you use a DataGridView to display data from a data source, the columns in the data source's schema sometimes do not appear in the order you would like to display them. You can change the displayed order of the columns by using the DisplayIndex property of the DataGridViewColumn class.


1 Answers

With the DisplayIndex property

myGridView.Columns["myFirstCol"].DisplayIndex = 0;
myGridView.Columns["mySecondCol"].DisplayIndex = 1;
like image 113
Paolo Falabella Avatar answered Oct 05 '22 22:10

Paolo Falabella