Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. RE: Save user's re-order grid preferences

RE: Save user's re-order grid preferences

Scheduled Pinned Locked Moved C#
cssquestion
8 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    roman_s
    wrote on last edited by
    #1

    So I've set my grid to allowReorder , this causes persistence on the grid order but once the program is restarted it goes back to default can someone let me know how I can save a user's re-order preference. Thinking it can be a property? If not maybe build a method to take care of this

    S P M 3 Replies Last reply
    0
    • R roman_s

      So I've set my grid to allowReorder , this causes persistence on the grid order but once the program is restarted it goes back to default can someone let me know how I can save a user's re-order preference. Thinking it can be a property? If not maybe build a method to take care of this

      S Offline
      S Offline
      Searril
      wrote on last edited by
      #2

      In your DataGridView look at the ColumnHeaderMouseClick event. You can gather DataGridView1.SortedColumn.Index to know which column is being sorted on and DataGridView1.SortOrder to see if ascending or descending. Then next time you refill the grid sort on that column and order.

      Richard Andrew x64R 1 Reply Last reply
      0
      • S Searril

        In your DataGridView look at the ColumnHeaderMouseClick event. You can gather DataGridView1.SortedColumn.Index to know which column is being sorted on and DataGridView1.SortOrder to see if ascending or descending. Then next time you refill the grid sort on that column and order.

        Richard Andrew x64R Offline
        Richard Andrew x64R Offline
        Richard Andrew x64
        wrote on last edited by
        #3

        I think he was asking about the order that the columns appear, left to right.

        S 1 Reply Last reply
        0
        • R roman_s

          So I've set my grid to allowReorder , this causes persistence on the grid order but once the program is restarted it goes back to default can someone let me know how I can save a user's re-order preference. Thinking it can be a property? If not maybe build a method to take care of this

          P Offline
          P Offline
          PIEBALDconsult
          wrote on last edited by
          #4

          So persist it, big deal.

          1 Reply Last reply
          0
          • R roman_s

            So I've set my grid to allowReorder , this causes persistence on the grid order but once the program is restarted it goes back to default can someone let me know how I can save a user's re-order preference. Thinking it can be a property? If not maybe build a method to take care of this

            M Offline
            M Offline
            Mycroft Holmes
            wrote on last edited by
            #5

            As piebald suggested persist the order for each user. I use XML and store that sort of thing in the users application data folder. ASP would use a cookie.

            Never underestimate the power of human stupidity RAH

            R 1 Reply Last reply
            0
            • Richard Andrew x64R Richard Andrew x64

              I think he was asking about the order that the columns appear, left to right.

              S Offline
              S Offline
              Searril
              wrote on last edited by
              #6

              Ugh, that's what I get for not reading thoroughly.

              1 Reply Last reply
              0
              • M Mycroft Holmes

                As piebald suggested persist the order for each user. I use XML and store that sort of thing in the users application data folder. ASP would use a cookie.

                Never underestimate the power of human stupidity RAH

                R Offline
                R Offline
                roman_s
                wrote on last edited by
                #7

                yes I persist on columnheaderclick. So it looks like I would have to save the column header index when user navigates from that specific panel. question is: (XML is going to be best option) each column will have an index.. on build the grid builds the columns in order to the columns index. what columnheader property is this and how would I go on to save and read from xml to populate these index #s

                M 1 Reply Last reply
                0
                • R roman_s

                  yes I persist on columnheaderclick. So it looks like I would have to save the column header index when user navigates from that specific panel. question is: (XML is going to be best option) each column will have an index.. on build the grid builds the columns in order to the columns index. what columnheader property is this and how would I go on to save and read from xml to populate these index #s

                  M Offline
                  M Offline
                  Mycroft Holmes
                  wrote on last edited by
                  #8

                  I use xml in this article[^] You can set the column index at runtime or construct the DGV from code or you can reorder the underlying data source to reflect the column choice. Lots of choices.

                  Never underestimate the power of human stupidity RAH

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups