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