[VB.NET] Problème affichage collections dans listbox [VB.NET]
Problème affichage collections dans listbox [VB.NET] [VB.NET] - VB/VBA/VBS - Programmation
Sujets relatifs:
Leave a Replay
Make sure you enter the(*)required information where indicate.HTML code is not allowed
Marsh Posté le 21-02-2014 à 08:41:03
Bonjour,
Je suis débutant en VB.NET et je m'exerce à concevoir une appli de bibliothèque de films. Cependant je n'arrive pas à afficher les élements d'une liste dans une listbox. Pouvez-vous m'aider??
Voici le code
Public Class Films
Private Nom As String
Private Type As String
Private Annee As Integer
Private Description As String
'Sub New()
'End Sub
Sub New(ByVal NomFilm As String, ByRef TypeFilm As String, ByVal AnneeFilm As Integer, ByVal DescriptionFilm As String)
NomFilm = Nom
TypeFilm = Type
AnneeFilm = Annee
DescriptionFilm = Description
End Sub
Public Property Name As String
Get
Return Nom
End Get
Set(value As String)
Nom = value
End Set
End Property
Public Property Year As Integer
Get
Return Annee
End Get
Set(value As Integer)
Annee = value
End Set
End Property
Public Property Tipe As String
Get
Return Type
End Get
Set(value As String)
Type = value
End Set
End Property
Public Property Propriete As String
Get
Return Description
End Get
Set(value As String)
Description = value
End Set
End Property
Public Function Affiche()
Return Nom
End Function
End Class
Public Class Accueil
Dim ListeDeFilms As New List(Of Films)
Private Sub Accueil_Load(sender As Object, e As EventArgs) Handles MyBase.Load
ListeDeFilms.Add(New Films("Terminator 1", "Action", 1984, "Terminator 1, film d'action de James Cameron" ))
ListeDeFilms.Add(New Films("Terminator 2", "Action", 1995, "Terminator 2, film d'action de James Cameron" ))
ListeDeFilms.Add(New Films("Terminator 3", "Action", 1984, "Terminator 3, film d'action de Michael Ferris" ))
For Each Film As Films In ListeDeFilms
ListBox1.Items.Add(Film.Affiche)
Next
End Sub
End Class