CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
+ Reply to Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2012
    Posts
    16

    sort numbers from lowest to highest in datagrid table

    How to sort numbers from lowest to highest in my datagrid table?
    Attached Images  

  2. #2
    Cimperiali's Avatar
    Cimperiali is offline Old Uncle Moderator Power Poster Cimperiali is a name known to all (1000+) Cimperiali is a name known to all (1000+) Cimperiali is a name known to all (1000+) Cimperiali is a name known to all (1000+) Cimperiali is a name known to all (1000+) Cimperiali is a name known to all (1000+) Cimperiali is a name known to all (1000+) Cimperiali is a name known to all (1000+) Cimperiali is a name known to all (1000+)
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,722

    Re: sort numbers from lowest to highest in datagrid table

    Code:
    DataGridView1.Sort(DataGridView1.Columns(0), System.ComponentModel.ListSortDirection.Ascending)
    by the way:

    First of all, your grid should have a datatsource (which could even be a List Of integers, for example)
    and you should mainly add, remove or sort the underlying datasource.
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

  3. #3
    Join Date
    Jan 2012
    Posts
    16

    Re: sort numbers from lowest to highest in datagrid table

    It's not working because if I enter number "35" and then "99" and then "353".They are sorted by:
    35
    353
    99
    why??
    99 is less than 353.

  4. #4
    Cimperiali's Avatar
    Cimperiali is offline Old Uncle Moderator Power Poster Cimperiali is a name known to all (1000+) Cimperiali is a name known to all (1000+) Cimperiali is a name known to all (1000+) Cimperiali is a name known to all (1000+) Cimperiali is a name known to all (1000+) Cimperiali is a name known to all (1000+) Cimperiali is a name known to all (1000+) Cimperiali is a name known to all (1000+) Cimperiali is a name known to all (1000+)
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,722

    Re: sort numbers from lowest to highest in datagrid table

    oppssss. That is because it looks at it as strings. you should implement a comparer
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

+ Reply to Thread

Bookmarks

Posting Permissions

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



HTML5 Development Center

Click Here to Expand Forum to Full Width