Listview

cloez Messages postés 1 Date d'inscription samedi 7 février 2004 Statut Membre Dernière intervention 7 février 2004 - 7 févr. 2004 à 16:56
cs_labout Messages postés 1356 Date d'inscription samedi 8 décembre 2001 Statut Membre Dernière intervention 23 octobre 2006 - 7 févr. 2004 à 18:33
Bonjour,

Nouveau dans le monde de VB je dois réliser une interface qui récupère des données provenant d'une BDD..
Ceci au travers d'une listview
Je ne sais pas du tout comment alimenter cette listview afin de lire les infos et pouvoir les selectionner
quelqu'un peut t'il venir à mon secours
urgent
merci
Clo

1 réponse

cs_labout Messages postés 1356 Date d'inscription samedi 8 décembre 2001 Statut Membre Dernière intervention 23 octobre 2006 8
7 févr. 2004 à 18:33
labout
Dans l'exemple qui suit j'ai un ListView nommé ListViewLot
Toutes les propriétés ou presque sont dans le code qui suit.
A adapter en fonction du contenu des éléments du recordset.

Dim itmX As ListItem
Dim sReq As String
dim cndata as new adodb.connection ' il faut inclure la référence ADODB dans le projet
'définir la connection cndata
cndata.connectstring="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\Incident.MDB;Mode=ReadWrite|Share Deny None;Persist Security Info=False;" & _
"Jet OLEDB:Create System Database=True;Jet OLEDB:Compact Without Replica Repair=True"
cndata.open
req = "select * "
req = req & "from lot "
req = req & "where datetraitement=cdate('" & DateTraitement & "') "
req = req & " and institution='" & Index & "'"
req = req & " order by NumeroLot"
Set rsLot = New ADODB.Recordset
rsLot.Open req, CnData, adOpenDynamic, adLockOptimistic

With ListViewLot
.SmallIcons = ImageList1
.ColumnHeaders.Clear
.ListItems.Clear
' Ajout des colonnes avec leur titre et la taille
.ColumnHeaders.Add , , "", 0, lvwColumnLeft
.ColumnHeaders.Add , , "N° Lot", .width / 12.5, lvwColumnRight
.ColumnHeaders.Add , , "Date Trt", .width / 7.5, lvwColumnRight
.ColumnHeaders.Add , , "Nb Tr.", .width / 10.5, lvwColumnRight
.ColumnHeaders.Add , , "Nb Chq", .width / 10.5, lvwColumnRight
.ColumnHeaders.Add , , "Montant Déclaration", .width / 5.2, lvwColumnRight
.ColumnHeaders.Add , , "Montant Chèque", .width / 6, lvwColumnRight
.ColumnHeaders.Add , , "Solde Payé", .width / 6, lvwColumnRight
.ColumnHeaders.Add , , "Institution", 0, lvwColumnRight
.ColumnHeaders.Add , , "Appel", .width / 13, lvwColumnCenter
.ColumnHeaders.Add , , "Néant", 0, lvwColumnRight
.ColumnHeaders.Add , , "A/S CHQ", 0, lvwColumnRight
.ColumnHeaders.Add , , "Date Récep.", .width / 7.5, lvwColumnRight
.ColumnHeaders.Add , , "Verif Chq", .width / 9, lvwColumnRight
.ColumnHeaders.Add , , "Verif Cot", .width / 9, lvwColumnRight

' Définit la vue Détails.
.View = lvwReport
'Ajout des données
While Not rsLot.EOF
DoEvents
Set itmX = .ListItems.Add(, , rsLot!CleLot)
If rsLot.Fields("Importe").Value = True Then
itmX.SmallIcon = 4
.ColumnHeaders(1).width = 220
.ColumnHeaders(1).Text = "I"
End If
itmX.SubItems(1) = rsLot!NumeroLot
itmX.SubItems(2) = rsLot!DateTraitement
itmX.SubItems(3) = CStr(IIf(IsNull(rsLot!NbTotTransaction), 0, rsLot!NbTotTransaction))
itmX.SubItems(4) = CStr(IIf(IsNull(rsLot!NbTotChq), 0, rsLot!NbTotChq))
itmX.SubItems(5) = CStr(IIf(IsNull(rsLot!MtTotDeclaration), 0, rsLot!MtTotDeclaration))
itmX.SubItems(6) = CStr(IIf(IsNull(rsLot!MtTotChq), 0, rsLot!MtTotChq))
itmX.SubItems(7) = CStr(IIf(IsNull(rsLot!MtSolde), 0, rsLot!MtSolde))
itmX.SubItems(8) = rsLot!institution
itmX.SubItems(9) = IIf(rsLot!BordereauTrimestriel, "I", "R")
itmX.SubItems(10) = rsLot!LotBorNeant
itmX.SubItems(11) = IIf(rsLot!LotBorseul, 0, -1)
itmX.SubItems(12) = rsLot!datereception
itmX.SubItems(13) = sVerif
itmX.SubItems(14) = sverifCotis
rsLot.MoveNext
Wend


End With
0
Rejoignez-nous