Je fouillais sur des site de programmation pour trouver une info et j’ai trouvé ça. C’est une petite référence, qui la trouvera ? Un indice dans le titre.
Public Shared Sub Main() Application.Run(New Form1()) End Sub ' Populates the DataGridView. ' Replace this with your own code to populate the DataGridView. Public Sub PopulateDataGridView() ' Add columns to the DataGridView. dataGridView1.ColumnCount = 2 dataGridView1.Columns(0).HeaderText = "Last Name" dataGridView1.Columns(1).HeaderText = "City" ' Put the new columns into programmatic sort mode dataGridView1.Columns(0).SortMode = _ DataGridViewColumnSortMode.Programmatic dataGridView1.Columns(1).SortMode = _ DataGridViewColumnSortMode.Programmatic ' Populate the DataGridView. dataGridView1.Rows.Add(New String() {"Parker", "Seattle"}) dataGridView1.Rows.Add(New String() {"Watson", "Seattle"}) dataGridView1.Rows.Add(New String() {"Osborn", "New York"}) dataGridView1.Rows.Add(New String() {"Jameson", "New York"}) dataGridView1.Rows.Add(New String() {"Brock", "New Jersey"}) End Sub Private Sub SortButton_Click(ByVal sender As Object, _ ByVal e As EventArgs) Handles sortButton.Click ' Check which column is selected, otherwise set NewColumn to Nothing. Dim newColumn As DataGridViewColumn If dataGridView1.Columns.GetColumnCount(DataGridViewElementStates _ .Selected) = 1 Then newColumn = dataGridView1.SelectedColumns(0) Else newColumn = Nothing End If Dim oldColumn As DataGridViewColumn = dataGridView1.SortedColumn Dim direction As ListSortDirection End Sub