Sort datagridview column 1 then column 2

Posted on 2007-08-02
Last Modified: 2013-11-26
Visual Basic 2005.
Databound form.

I have this code in form load:
 Me.MyDataGridView.Sort(MyDataGridView.Columns(1), System.ComponentModel.ListSortDirection.Ascending)

I need sample code to sort column 2 (the rows would sort by column 1 first and then by column 2).
Question by:dave_sky
    LVL 6

    Accepted Solution

    If the DataSource for MyGridView is a BindingSource, try this(replace column names):

    MyBindingSource.Sort = "column1name ASC, column2name ASC"

    Author Comment



    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (…
    A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    9 Experts available now in Live!

    Get 1:1 Help Now