[RESOLVED] DataGridView and column changes
Hi,
I have a datagridview (dgv) and if the user changes the size of a column or moves the column to the left or right, I want to be able to save those changes, so when the user sign's on again, the dgv will show as it was when the user closed out of it. Is there a way to do this?
Also, is there a way to "freeze" columns? For example if I have 10 columns, I freeze column's 1 and 2 (to the left) so whenever the user scroll's over to the right, column's 1 and 2 will stay on the screen.
Re: DataGridView and column changes
With regards to your second question, if you want to do something with a DataGridViewColumn then would it not make sense to read the documentation for the DataGridViewColumn class? If you'd done that then you'd have seen the Frozen property for yourself and never had to ask the question. Always read the documentation first.
The first question is not one that the documentation for that class would answer because it's more complex than setting a single property. For this, you would most likely use My.Settings. Assuming that you have added the column in the designer, select it in the Properties window and then use the (ApplicationSettings) node to create a setting and bind it to the Width property. Now the value of that property will be automatically saved and loaded.
If the column wasn't added in the designer then you can still create the setting manually on the Settings page of the project properties, then write code to save and load the value manually too.