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. Datagridview sort by 2 Column??? [modified]

Datagridview sort by 2 Column??? [modified]

Scheduled Pinned Locked Moved C#
helptutorialquestion
2 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.
  • S Offline
    S Offline
    shfaye
    wrote on last edited by
    #1

    hi, i have a problem with datagridview sort methode. i doono whether i can sort datagridview by 2 Columns. there's example username--------actionType--------filename user1-----------download----------picture1.tiff ----------------upload------------picture2.jpg ----------------upload------------picture3.tiff user3-----------download----------file1.txt ----------------download----------file2.txt admin1----------upload -----------config.cfg ----------------download----------db1.mdb so there i wanna sort the table by 'filename' and 'username', i mean the order of username Column should not change but the order of 'filename' and the association of 'username' and 'filename' should not change neither. just like the effect in slq 'order by username, filename' has anyone a idea? regards faye -- modified at 4:54 Monday 15th January, 2007

    L 1 Reply Last reply
    0
    • S shfaye

      hi, i have a problem with datagridview sort methode. i doono whether i can sort datagridview by 2 Columns. there's example username--------actionType--------filename user1-----------download----------picture1.tiff ----------------upload------------picture2.jpg ----------------upload------------picture3.tiff user3-----------download----------file1.txt ----------------download----------file2.txt admin1----------upload -----------config.cfg ----------------download----------db1.mdb so there i wanna sort the table by 'filename' and 'username', i mean the order of username Column should not change but the order of 'filename' and the association of 'username' and 'filename' should not change neither. just like the effect in slq 'order by username, filename' has anyone a idea? regards faye -- modified at 4:54 Monday 15th January, 2007

      L Offline
      L Offline
      Lisa Jorgensen
      wrote on last edited by
      #2

      Use a BindingSource to bind your table to the DataGridView, then use the BindingSource's Sort property to specify the columns and directions to sort. E.g.:

      bindingSource.Sort = "username, filename";

      You can also specify the direction of the sort, e.g.:

      bindingSource.Sort = "username ASC, filename DESC";

      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