4
Contributors
4
Replies
6
Views
6 Years
Discussion Span
Last Post by markdean.expres
0

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
0

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.

0

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.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.