DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Sorting DataGridView & Keeping Rows In a bunch

  1. #1
    Join Date
    Jan 2007
    Posts
    92

    Sorting DataGridView & Keeping Rows In a bunch

    i am trying to do two things inside the datagridview. i have a datagridview that show the details of orders. i want to sort the grid by ROUTE then sub sort by ORDER# then sub sort by LINE NUMBER

    1. is there a way to do that type of sorting
    2. if there is not a way to do that type of sorting is there a way of grouping rows together. for example can i make each order a group so when i sort it knows to keep all those rows together

  2. #2
    Join Date
    Jun 2004
    Posts
    93
    In a datagridview, you have the option to perform your own sorting on the items. The DGV object contains a Sort method that you can pass a class that implements IComparer.

    You create this class and handle the compare through a Compare function where you are passed 2 DataGridViewRow items and you need to say which is greater (or if they are equal).

    Inside of the Compare, you can do anything you want to determine the order including looking at multiple column/call values.

    See "Custom Sorting Using the IComparer Interface " on the following page:
    http://msdn2.microsoft.com/en-us/library/ms171608.aspx

Similar Threads

  1. DataGridView Returning Values from Cells
    By triley35 in forum .NET
    Replies: 1
    Last Post: 07-08-2006, 12:34 AM
  2. Sorting DataGridView
    By alphaoide in forum ASP.NET
    Replies: 2
    Last Post: 04-02-2006, 03:18 AM
  3. Deleteing rows in a Datagridview
    By filippo.monti in forum .NET
    Replies: 1
    Last Post: 11-28-2005, 04:57 PM
  4. Paging and Sorting in DataGrid
    By THL in forum ASP.NET
    Replies: 4
    Last Post: 09-08-2005, 10:39 PM
  5. Replies: 16
    Last Post: 04-26-2002, 02:35 PM

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
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center