• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 661
  • Last Modified:

Sort datagridview column 1 then column 2

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).
0
dave_sky
Asked:
dave_sky
1 Solution
 
ToFroCommented:
If the DataSource for MyGridView is a BindingSource, try this(replace column names):

MyBindingSource.Sort = "column1name ASC, column2name ASC"
0
 
dave_skyAuthor Commented:
Excellent!

Thanks
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now