bonjour à tous, je voudrais trier mon datagridview selon une colonne et si les cellules contiennent la même chose, ensuite trier sur une autre;
j'ai testé ce code:
(http://msdn.microsoft.com/fr-fr/libr...171608.aspx#Y0)
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 Private Sub DataGridView1_SortCompare( _ ByVal sender As Object, ByVal e As DataGridViewSortCompareEventArgs) _ Handles DataGridView1.SortCompare ' Try to sort based on the contents of the cell in the current column. e.SortResult = System.String.Compare(e.CellValue1.ToString(), _ e.CellValue2.ToString()) ' If the cells are equal, sort based on the ID column. If (e.SortResult = 0) AndAlso Not (e.Column.Name = "ID") Then e.SortResult = System.String.Compare( _ DataGridView1.Rows(e.RowIndex1).Cells("ID").Value.ToString(), _ DataGridView1.Rows(e.RowIndex2).Cells("ID").Value.ToString()) End If e.Handled = True End Sub
mais qu'il soit là ou pas, je ne vois aucune différence...
j'ai essayé en mettant sort mode automatic et programatic...
merci d'avance à ceux qui éclaireront ma lanterne...
Partager