Results 1 to 2 of 2

Thread: [RESOLVED] DataGridView and column changes

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2011
    Posts
    72

    Resolved [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.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width