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?
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.
With the DisplayIndex property
myGridView.Columns["myFirstCol"].DisplayIndex = 0;
myGridView.Columns["mySecondCol"].DisplayIndex = 1;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With