Guys, is there a way to programatically and more efficiently sort records displayed in a datagridview control? If so, how?

Guys, is there a way to programatically and more efficiently sort records displayed in a datagridview control? If so, how?

Required: CheckBox and DatagridView
Checboxname = chkboxDesc
DatagridView = DatagridView1

Private Sub chkboxDesc_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkboxDesc.CheckedChanged
        If chkboxDesc.Checked = True Then
            DatagridView1.Sort(DatagridView1.Columns(0), _
              System.ComponentModel.ListSortDirection.Descending)
        ElseIf chkboxDesc.Checked = False Then
            DatagridView1.Sort(DatagridView1.Columns(0), _
             System.ComponentModel.ListSortDirection.Ascending)
        End If
    End Sub

Guys, is there a way to programatically and more efficiently sort records displayed in a datagridview control? If so, how?

Hi,

You should use the Datagridview.Sort method.
You can make your sorting in a ascending or decending direction.

You can find an example, here.

If you are not going to sort your rows at runtime you can also sort them when you retrieve them from the Database

This question has already been answered. Start a new discussion instead.