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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Help With Sorting Multiple dataGridView Columns

Help With Sorting Multiple dataGridView Columns

Scheduled Pinned Locked Moved C#
algorithmshelptutorialquestionlounge
3 Posts 2 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.
  • T Offline
    T Offline
    That Asian Guy
    wrote on last edited by
    #1

    When I sort columnA in dataGridView, the column sorts properly, but if a lot of values are the same in columnA, the values in columnB are random. Example:

    columnA columnB
    a t
    a w
    a r
    a a
    a n
    a e
    b a
    b f
    b b
    c a
    d a

    How do I get my program to sort so that it will sort columnB after columnA such that:

    a a
    a e
    a n
    a r
    a t
    a w
    b a
    b b
    b f
    c a
    d a

    Thanks in advance.

    D 1 Reply Last reply
    0
    • T That Asian Guy

      When I sort columnA in dataGridView, the column sorts properly, but if a lot of values are the same in columnA, the values in columnB are random. Example:

      columnA columnB
      a t
      a w
      a r
      a a
      a n
      a e
      b a
      b f
      b b
      c a
      d a

      How do I get my program to sort so that it will sort columnB after columnA such that:

      a a
      a e
      a n
      a r
      a t
      a w
      b a
      b b
      b f
      c a
      d a

      Thanks in advance.

      D Offline
      D Offline
      DaveyM69
      wrote on last edited by
      #2

      Google search for dataGridView1.Sort[^] - the second result was this MSDN page[^]. The very last example at the bottom of the page does exactly what you want. Remember, always search first before posting. You'd have found it for yourself long ago instead of waiting around hoping someone replies.

      Dave
      BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
      Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)

      T 1 Reply Last reply
      0
      • D DaveyM69

        Google search for dataGridView1.Sort[^] - the second result was this MSDN page[^]. The very last example at the bottom of the page does exactly what you want. Remember, always search first before posting. You'd have found it for yourself long ago instead of waiting around hoping someone replies.

        Dave
        BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
        Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)

        T Offline
        T Offline
        That Asian Guy
        wrote on last edited by
        #3

        Haha, I tried reading the IComparer page before but didn't quite get it. This one was much easier to read, thanks!

        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