hitman00
Messages postés23Date d'inscriptionlundi 28 juillet 2003StatutMembreDernière intervention 5 décembre 2005
-
28 févr. 2005 à 16:23
hitman00
Messages postés23Date d'inscriptionlundi 28 juillet 2003StatutMembreDernière intervention 5 décembre 2005
-
28 févr. 2005 à 16:59
Coucou a tous ,j'ai une petit probleme avec ma listview
j'arrive a recuperer le nom des colones dans la listview mais impossible de recuperer les champs je vois jete mon code si quelqu'un peut me donner un coup de mais cela m arrangerais enormement
Merci d'avance
Private Sub Form_Load()
Dim Ct As ADODB.Connection
Dim rc As ADODB.Recordset
Dim Base As String
Dim ItemX As ListItem
Dim i As Integer
Set Ct = New ADODB.Connection
Ct.Provider = "Microsoft OLE DB Provider For SQL Server"
Ct.ConnectionString = "Provider=MSDASQL;DSN=eole DSN;UID=Staff;PWD=winacti;"
Ct.Open
Set rc = New ADODB.Recordset
rc.Open "SELECT Staff.ACTION.BATIMENT , Staff.ACTION.ETAGE, Staff.ACTION.BUREAU, Staff.ACTION.INTERVENANT, Staff.DEMANDE.NO_DEMANDE, Staff.DEMANDE.LIBELLE_DU_CONTRAT, Staff.DEMANDE.DEMANDEUR FROM Staff.ACTION, Staff.INTVENAN, Staff.DEMANDE WHERE Staff.ACTION.CLE_INTERVENANT Staff.INTVENAN.CLE_INTERVENANT AND Staff.ACTION.CLE_DEMANDE Staff.DEMANDE.CLE_DEMANDE AND Staff.INTVENAN.BUREAU = 'D487' AND (Staff.ACTION.FIN_REELLE IS NULL)
ListView1.GridLines = True ' pour afficher les séparations entre lignes et colonnes
ListView1.FullRowSelect = True ' pour la sélection de la ligne entière
ListView1.View = lvwReport ' affichage détails
ListView1.LabelEdit = lvwManual
' Nom des colonnes
For Each fld In rc.Fields
ListView1.ColumnHeaders.Add , , fld.Name, ListView1.Width / rc.Fields.Count
Next
Do Until rc.EOF
rc.MoveNext
Loop
' Remplir la listview
Do While Not rc.EOF
Set ItemX = ListView1.ListItems.Add(, , rc.Fields(0))
For i = 1 To rc.Fields.Count - 1
ItemX.SubItems(i) = rc.Fields(i)
mrdep1978
Messages postés402Date d'inscriptionjeudi 25 novembre 2004StatutMembreDernière intervention 7 juin 20097 28 févr. 2005 à 16:49
Nom des colonnes
For Each fld In rc.Fields
ListView1.ColumnHeaders.Add , , fld.Name, ListView1.Width / rc.Fields.Count
Next
'Pourquoi as-tu mis ça ???? Tu vas à la fin de ton recordset. Donc, ....
Do Until rc.EOF
rc.MoveNext
Loop
' Remplir la listview
'... quand tu arrives ici, tu as tout de suite rc.EOF = True et tu ne rentres pas dans ta boucle de remplissage
Do While Not rc.EOF
Set ItemX = ListView1.ListItems.Add(, , rc.Fields(0))
For i = 1 To rc.Fields.Count - 1
ItemX.SubItems(i) = rc.Fields(i)
Next