Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to stop datagridview columns being reset

Status
Not open for further replies.

misterstick

Programmer
Apr 7, 2000
633
GB
i have a datagridview on a form.
the form sets the datasource for the grid in the load event handler, to a BindingList<> of custom objects.
the fields on the custom objects have relatively unfriendly names, are in the wrong order, and there are extra ones for housekeeping that the user does not need to see.
the form, therefore, at the end of the load event handler sets the columns on the grid to be more user-friendly.
i've checked the columns just before the last "}" in the handler and they are correct.
when the form is displayed, though, the columns are back in their original order.
any ideas why this should be happening?
or even when?


mr s. <;)

 
Look for the AutoGenerateColumns property of the grid. It must be set to false.
 
doesn't work for me, i'm afraid.

surely AutoGenerateColumns only kicks in when the DataSource or Datamember are set. my problem is that i've set the DataSource then the columns, but .Net is resetting them in the limbo between the form_Load event and the form actually displaying.

is there something i'm missing?


mr s. <;)

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top