1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| Private Sub DataGridView1_CellValueChanged(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellValueChanged
'--- Récupération des notes dans une liste.
Dim listNotes As New List(Of Double)
If col = 1 Then
For i As Integer = 0 To DataGridView1.RowCount - 1
If DataGridView1.Rows(i).Cells(1).Value IsNot Nothing Then
listNotes.Add(CDbl(DataGridView1.Rows(i).Cells(1).Value.ToString))
End If
Next
'--- Tri de cette liste, ordre décroissant.
Dim reverseComp As Comparison(Of Double) = Function(x, y) y.CompareTo(x)
listNotes.Sort(reverseComp)
End If
'--- Recherche de l'index dans la liste de la note cherchée.
'--- Vu que cette fonction ne s'occupe que de la 1ère occurrence trouvée, les ex aequo sont traités
For i As Integer = 0 To DataGridView1.RowCount - 1
If DataGridView1.Rows(i).Cells(1).Value IsNot Nothing Then
DataGridView1.Rows(i).Cells(2).Value = listNotes.IndexOf(CDbl(DataGridView1.Rows(i).Cells(1).Value)) + 1
End If
Next
End Sub |
Partager