High-Tech
Santé-Médecine
Droit-Finances
CodeS-SourceS
Inscription
Plan
Connexion
Rechercher un code, un tuto, une réponse
Accueil
Forum
Tutoriels
Codes Sources
Snippets
Top membres
Tous les langages
Delphi / Pascal
Java
Python
SQL
RegEx
Flash
ASM
IRC
Graphisme
PDA
ColdFusion
Foxpro
Flex
Visual Basic / VB.NET
Forum
Tutoriels
Codes Sources
Snippets
Top membres
PHP
Forum
Tutoriels
Codes Sources
Snippets
Top membres
C/C++/C++.NET
Forum
Tutoriels
Codes Sources
Snippets
Top membres
Javascript
Forum
Tutoriels
Codes Sources
Snippets
Top membres
C#/.NET
Forum
Tutoriels
Codes Sources
Snippets
Top membres
ASP/ASP.NET
Forum
Tutoriels
Codes Sources
Snippets
Top membres
Accueil
Connexion
Déposer un code
Code
Recherche
Haut
Accueil
Forum Codes-Sources
Commentaires sur une source
TRI D'UN OBJET GRID À PARTIR D'UNE COLONE RÉFÉRENTE
Signaler
tdihedi
Messages postés
3
Date d'inscription
mardi 6 avril 2004
Statut
Membre
Dernière intervention
4 mai 2004
-
4 mai 2004 à 14:24
tdihedi
Messages postés
3
Date d'inscription
mardi 6 avril 2004
Statut
Membre
Dernière intervention
4 mai 2004
-
4 mai 2004 à 17:48
Cette discussion concerne un article du site. Pour la consulter dans son contexte d'origine, cliquez sur le lien ci-dessous.
https://codes-sources.commentcamarche.net/source/114-tri-d-un-objet-grid-a-partir-d-une-colone-referente
Signaler
tdihedi
Messages postés
3
Date d'inscription
mardi 6 avril 2004
Statut
Membre
Dernière intervention
4 mai 2004
4 mai 2004 à 17:48
Mais je crois que la meilleure solution reste quand même
Grid.Sort = 1
c'est beaucoup plus rapide
Signaler
tdihedi
Messages postés
3
Date d'inscription
mardi 6 avril 2004
Statut
Membre
Dernière intervention
4 mai 2004
4 mai 2004 à 14:24
Merci pour l'auteur de ce code
Si vous essayez ce code vous allez voir qu'il ya quelques bugs:
par exemple le fait que la ligne de titre soit incluse
voici le code modifié:
Private Sub SortedGrid(ByVal Col As Integer)
Dim ct As Integer, ct2 As Integer, swapRow As Integer
Dim curVal, oldVal
Dim Change As Boolean
If Col < 0 And Col > Grid.Cols - 1 Then Exit Sub
Change = True
Do While Change
Change = False
For ct = Grid.Rows - 1 To Grid.FixedRows Step -1
Grid.Row = ct
Grid.Col = Col
oldVal = Grid.Text
swapRow = ct
For ct2 = ct To Grid.FixedRows Step -1
Grid.Row = ct2
Grid.Col = Col
If oldVal < Grid.Text Then
Call SwapRowGrid(swapRow, ct2)
swapRow = ct2
Change = True
ElseIf oldVal > Grid.Text Then
Exit For
End If
Next
Next
Loop
End Sub
Votre réponse
A voir également
Visual Basic / VB.NET : Tri d'un objet grid à partir d'une colone référente - C
Permute deux lignes d'un objet grid
Trier tableau d'objet
Trier un listview par clic sur l'entête de colonne et couleur + ajustement auto vb.net
Trier vos donnees en cliquant sur les entetes de colonnes
Grid.Sort = 1
c'est beaucoup plus rapide
Si vous essayez ce code vous allez voir qu'il ya quelques bugs:
par exemple le fait que la ligne de titre soit incluse
voici le code modifié:
Private Sub SortedGrid(ByVal Col As Integer)
Dim ct As Integer, ct2 As Integer, swapRow As Integer
Dim curVal, oldVal
Dim Change As Boolean
If Col < 0 And Col > Grid.Cols - 1 Then Exit Sub
Change = True
Do While Change
Change = False
For ct = Grid.Rows - 1 To Grid.FixedRows Step -1
Grid.Row = ct
Grid.Col = Col
oldVal = Grid.Text
swapRow = ct
For ct2 = ct To Grid.FixedRows Step -1
Grid.Row = ct2
Grid.Col = Col
If oldVal < Grid.Text Then
Call SwapRowGrid(swapRow, ct2)
swapRow = ct2
Change = True
ElseIf oldVal > Grid.Text Then
Exit For
End If
Next
Next
Loop
End Sub