puisque tu ne nous parles :
- ni de dans quoi et avec quel code tu les enregistres !
- ni de l'évènement utilisé pour la récupération, ni du code utilisé pour la récupération !
En sortie de programme, je sauvegarde dans un fichier de paramètres les valeurs de : ListView.Sorted ListView.SortOrder ListView.SortKey Quand j'entre à nouveau dans le programme, je récupère ces données, et après l'initialisation de mon contrôle, j'essaie de les récupérer en lisant mon fichier :
Je ne comprend toujours pas la question. Mais puis que tu sembles y tenir, je vais l'expliciter un peu plus.
Dim Vlst as Tliste
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionMets-le, indenté, entre balises code (3ème icône en partant de la droite)
Type TListe CHK As Integer ' 0, rien = sélection unique, 1 multisélection, 2 cases à cocher CPT As Long ' nombre d'éléments total de la liste Elt As Long ' élément sélectionné KEY As Integer ' clé en cours (colonne tri) MAX As Long ' nombre d'éléments maxi de la liste NBC As Integer ' nombre de colonnes SRT As Integer ' 0 tri ascend, 1 descend End Type Public titi As TListe
Private Sub Form_Activate() ListView1.ColumnHeaders.Add , , "Nom", ListView1.Width / 3 ListView1.ColumnHeaders.Add , , "prénom ID", ListView1.Width / 3, lvwColumnCenter ListView1.ColumnHeaders.Add , , "date de naissance", ListView1.Width / 3 Randomize Dim itmX As ListItem For i = 1 To 10 Set itmX = ListView1.ListItems.Add(, , Chr(Int((10 * Rnd) + 64))) itmX.SubItems(1) = Chr(Int((10 * Rnd) + 64)) itmX.SubItems(2) = Chr(Int((10 * Rnd) + 64)) Next If Dir("d:\lst.txt") <> "" Then Open "d:\lst.txt" For Random As #1 Len = Len(titi) Get #1, 1, titi MsgBox titi.KEY & vbCrLf & titi.SRT Close #1 ListView1.Sorted = True ListView1.SortKey = Val(titi.KEY) ListView1.SortOrder = Val(titi.SRT) End If End Sub Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer) titi.KEY = 2 titi.SRT = lvwDescending Open "d:\lst.txt" For Random As #1 Len = Len(titi) Put #1, 1, titi Close #1 End Sub
Private Sub Form_Load() Dim Dum As Integer, Nprm As Integer, Fprm As String ' Récupération des paramètres ChmPrg = CurDir Fprm = ChmPrg & "\OuDonc.prm" Caption = "Ou donc, " & Format(Date, "dddd dd mmmm yyyy") 'GoTo Suite If Dir(Fprm) <> "" Then Nprm = FreeFile Open Fprm For Binary Access Read As #Nprm Get #Nprm, , Prm Close #Nprm '(Prm.Gauche, Prm.Haut, Prm.Large, Prm.Hauteur) Option2(1).Value = Prm.TypeList XLST.KEY = Prm.CleTri XLST.SRT = Prm.SensTri 'XLST.CLM = Prm.clmX DontResize = True Label3.Top = Prm.Label3Top Me.Left = Prm.Gauche Me.Top = Prm.Haut Me.Width = Prm.Large Me.Height = Prm.Hauteur Call Placer DontResize = False Call Form_Resize ChmExeZip = Prm.ChmExeZip ChmZip = Prm.ChmZip NomZip = Prm.NomZip Else Suite: Move (Screen.Width - Width) / 2, (Screen.Height - Height) / 2 XLST.KEY = 1 XLST.SRT = 0 End If 'Si le fichier des erreurs existe, il faut le détruire. If Dir(CurDir + "\Ou.log") <> "" Then Kill CurDir + "\Ou.log" ' Poser la feuille la feuille ' Définition de la ListView XLST.MAX = 999999999 XLST.NBC = 5 For Dum% = 0 To 1 If Option2(Dum%).Value = True Then XLST.CHK = Dum% + 1 Exit For End If Next Label3.Caption = "ABCD" 'OrgListViewLeft = Label3.Width OrgListViewLeft = Frame1.Left OrgListViewTop = Label3.Height OrgListViewWidth = Width - 2 * (OrgListViewLeft) OrgListViewHeight = Height - OrgListViewTop - (Height - Label3.Top) ' on place les Command3 Dim Vum& Vum = Command3(1).Top - Command3(0).Top Command3(0).Top = Command1(0).Top Command3(0).Left = Command1(0).Left For Dum = 1 To Command3.Count - 1 Command3(Dum).Top = Command3(Dum - 1).Top + Vum Command3(Dum).Left = Command1(0).Left Next ReDim tbl$(XLST.NBC, 2) tbl(1, 1) = "Fichiers" tbl(2, 1) = "Chemin" tbl(3, 1) = "Longueur" tbl(4, 1) = "Date" tbl(5, 1) = "Heure" ' Dimensionnement des colonnes ' on va utiliser les propriétés AutoSize de l'étiquette invisible ' VfBox.ColomnsWidth, pour dimensionner, les colonnes VListColumnFont "MS Sans Serif", 10 VListColumnWidth tbl(1, 2), String$(20, "X") VListColumnWidth tbl(2, 2), String$(50, "X") VListColumnWidth tbl(3, 2), String$(12, "X") VListColumnWidth tbl(4, 2), String$(12, "X") VListColumnWidth tbl(5, 2), String$(7, "X") VListInit ListView1, XLST, ImageList1, OrgListViewLeft, OrgListViewTop, OrgListViewWidth, OrgListViewHeight, tbl$() VListFont ListView1, "Courier new", 10 '*-*- ListView1.Sorted = True ListView1.SortOrder = XLST.SRT ListView1.SortKey = XLST.KEY '*-*- Debug.Print ListView1.SortKey Debug.Print ListView1.SortOrder . . . end sub
Option Explicit Type TPrm Gauche As Long Haut As Long Large As Long Hauteur As Long TypeList As Integer CleTri As Integer SensTri As Integer Label1Left As Long Label3Top As Long Label41Left As Long label42Left As Long Label4Top As Long Label2Left As Long Check1Top As Long Check1Left As Long Check3Top As Long Check4Top As Long Command1Top As Long Command1Left As Long Command2Left As Long Combo1Top As Long Frame1Top As Long Option2Top As Long ChmExeZip As String ' Chemin et nom du programme de Compression (program files\Winzip\Winzip32.exe ChmZip As String ' Chemin du dernier fichier Zip enregistré NomZip As String ' Nom du dernier fichier enregistré End Type Public OldFormWidth As Long Public OldFormHeight As Long Public OldListView1Height As Long Public OldListView1Width As Long Public OrgListViewLeft As Long Public OrgListViewTop As Long Public OrgListViewWidth As Long Public OrgListViewHeight As Long Public ChmExeZip As String Public ChmZip As String Public NomZip As String Public ChmPrg As String ' Chemin du programme OuDonc Public Attributs(7) As String Public AttrPpal As Integer Public AttrSecd As Integer Public Racine As String ' c'est la racine de la recherche Public DateToFind As String Public FTMP%, FileToFind As String Public XLST As TListe Public Btton_Attrib As Boolean Public TblCheck1() As Integer Public TblOpt1() As Integer Public TblCheck3 As Integer Public Prm As TPrm Public DontResize As Boolean Public FteFichier As Boolean Public SelectAll As Boolean ' drapeau selection tout ou rien
Option Explicit Type TListe CHK As Integer ' 0, rien = sélection unique, 1 multisélection, 2 cases à cocher CPT As Long ' nombre d'éléments total Elt As Long ' élément sélectionné KEY As Integer ' clé en cours (colonne tri) MAX As Long ' nombre d'éléments maxi de la liste NBC As Integer ' nombre de colonnes SRT As Integer ' 0 tri ascend, 1 descend End Type Public Type LV_ITEM Mask As Long Index As Long SubItem As Long State As Long StateMask As Long Text As String TextMax As Long Icon As Long Param As Long Indent As Long End Type