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. Sort DatagridView

Sort DatagridView

Scheduled Pinned Locked Moved C#
csharphelptutorialquestion
4 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.
  • A Offline
    A Offline
    aaraaayen 0
    wrote on last edited by
    #1

    Hi Friends, Sorry for repeating this question. How to sort the datagridview unbounded columns in c#.net.Its urgent for me. Please Help. Code: ICollection userDetails = new ArrayList(); domainUser = SessionData.LoginName; domainPassword = SessionData.Password; userDetails=GetAllUsers(DEFAULTDOMAIN, domainUser, domainPassword); (Here GetAllUsers is a method which returns all the user details from the domain). dgAddressBook.DataSource = userDetails; Full Details are listed in Datagridview. But I need to display the records based on the Column Firstname - ascending order). Thanks in Advance, Regards,

    Prya

    G 1 Reply Last reply
    0
    • A aaraaayen 0

      Hi Friends, Sorry for repeating this question. How to sort the datagridview unbounded columns in c#.net.Its urgent for me. Please Help. Code: ICollection userDetails = new ArrayList(); domainUser = SessionData.LoginName; domainPassword = SessionData.Password; userDetails=GetAllUsers(DEFAULTDOMAIN, domainUser, domainPassword); (Here GetAllUsers is a method which returns all the user details from the domain). dgAddressBook.DataSource = userDetails; Full Details are listed in Datagridview. But I need to display the records based on the Column Firstname - ascending order). Thanks in Advance, Regards,

      Prya

      G Offline
      G Offline
      Guffa
      wrote on last edited by
      #2

      If you are using framework 2, use a SortedList instead of ArrayList, or a List and use it's Sort method. Otherwise, you can use the Sort method of the ArrayList.

      --- Year happy = new Year(2007);

      A 1 Reply Last reply
      0
      • G Guffa

        If you are using framework 2, use a SortedList instead of ArrayList, or a List and use it's Sort method. Otherwise, you can use the Sort method of the ArrayList.

        --- Year happy = new Year(2007);

        A Offline
        A Offline
        aaraaayen 0
        wrote on last edited by
        #3

        THank u so much. I applied it like, ICollection userDetails = new SortedList(); But the contents are not sorted. Can u pls. suggest me what was the problem. Regards,

        Prya

        G 1 Reply Last reply
        0
        • A aaraaayen 0

          THank u so much. I applied it like, ICollection userDetails = new SortedList(); But the contents are not sorted. Can u pls. suggest me what was the problem. Regards,

          Prya

          G Offline
          G Offline
          Guffa
          wrote on last edited by
          #4

          The problem is that you are not using the list that you create in that line. The GetAllUsers method returns a new list and the first list is thrown away.

          --- Year happy = new Year(2007);

          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