Bonjour à tous,

Avec ma Class suivante :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<Serializable()> Public Class ListeDesArticles
    Inherits List(Of Article)
 
    <NonSerialized()> Const NOM_DU_FICHIER As String = "Les Articles.gdm"
    <NonSerialized()> Private Shared _Instance As ListeDesArticles 
 
    <NonSerialized()> Public Event ArticleEnregistre()
    <NonSerialized()> Public Event DonneesCharge()
    <NonSerialized()> Public Event DonneesEnregistre()
 
 
    ' Retourne la Liste des Articles.
    Public Shared Function GetInstance() As ListeDesArticles
        If IsNothing(_Instance) AndAlso File.Exists(My.Settings.DossierStockageParDefaut & NOM_DU_FICHIER) Then
            Load()
        ElseIf IsNothing(_Instance) AndAlso Not File.Exists(My.Settings.DossierStockageParDefaut & NOM_DU_FICHIER) Then
            SyncLock GetType(ListeDesArticles)
                _Instance = New ListeDesArticles
            End SyncLock
        End If
            Return _Instance
    End Function
 
    ' Charge le Fichier contenant les Données.
    Public Shared Sub Load(Optional Fichier As FileInfo = Nothing)
        Dim MonFichier As Stream
        If  Not IsNothing(Fichier) AndAlso Fichier.Exists Then
            MonFichier = File.OpenRead(Fichier.FullName)
        Else
            MonFichier = File.OpenRead(My.Settings.DossierStockageParDefaut & NOM_DU_FICHIER)
        End If
        Try
            Dim Charger As New BinaryFormatter()
            _Instance = CType(Charger.Deserialize(MonFichier), ListeDesArticles)
        Catch ex As Exception
            MsgBox(ex.Message)
        Finally
            MonFichier.Close()
        End Try
    End Sub
 
    ' Retourne l'Article correspondant à l'Identifiant.
    Public Overloads ReadOnly Property Item(Id As Integer) As Article
        Get
            If Count > 0 Then
                Return IIf(Count > 0, Find(Function(UnArticle) UnArticle.Id = Id), Nothing)
            Else
                Return Nothing
            End If
        End Get
    End Property
 
    ' Retourne l'Article correspondant à sa Désignation ou son NNO (Par défaut : NNO)
    Public Overloads ReadOnly Property Item(StrValue As String, Optional ParDefaut As Boolean = True) As Article
        Get
            If Count > 0 Then
                If ParDefaut Then
                    Return Find(Function(UnArticle) UnArticle.NNO = StrValue)
                Else
                    Return Find(Function(UnArticle) UnArticle.Designation = StrValue)
                End If
            Else
                Return Nothing
            End If
        End Get
    End Property
 
 
 
    ' Crée une Liste D'article ou Charge une Liste existante.
    Private Sub New()
        MyBase.New()
    End Sub
 
    ' Retourne tous les Articles correspondant à la Valeur Recherché.
    Public Overloads Function FindAll(StrValue As String, Optional Type As String = "NNO") As ListeDesArticles
        If Count > 0 Then
            Select Case Type.ToUpper
                Case "DESIGNATION"
                    Return FindAll(Function(UnArticle) UnArticle.Designation = "?" & StrValue & "?")
                Case "GISEMENT"
                    Return FindAll(Function(UnArticle) UnArticle.Gisement = "?" & StrValue & "?")
                Case Else
                    Return FindAll(Function(UnArticle) UnArticle.NNO = "?" & StrValue & "?")
            End Select
        Else
            Throw New ArgumentException("Aucun Articles n'est enregistrés.")
        End If
    End Function
 
    ' Retourne tous les Articles triés par Designation.
    Public Overloads Function Sort(NomDeColonne As String) As List(Of Article)
        If Count > 0 Then
            Select Case NomDeColonne
                Case "Designation"
                    Return (From Element In Me Select Element Order By Element.Designation Ascending).ToList
                Case "NNO"
                    Return (From Element In Me Select Element Order By Element.NNO Ascending).ToList
                Case "Emplacement"
                    Return (From Element In Me Select Element Order By Element.Emplacement Ascending).ToList
                Case "Installation"
                    Return (From Element In Me Select Element Order By Element.Installation Ascending).ToList
                Case Else
                    Throw New ArgumentException("Choix du filtrage inconnu.")
            End Select
        Else
            Throw New ArgumentException("Aucun Articles n'est enregistrés.")
        End If
    End Function
 
End Class
Ainsi avec une seule Procédure, je peux utiliser le même objet avec des Données différentes et trier.

Je souhaiterais pouvoir retourner un objet de type "ListeDesArticles" avec les fonction : "Sort" et "FindAll"
J'ai essayé de chercher sur me NET, mais je ne sais toujours pas comment faire et surtout si c'est possible.
Mon but étant de pouvoir faire :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
  Private Sub AffichageDesArticles(Liste As ListeDesArticles)
        ListeDesArticles_DTG.Rows.Clear()
        For Each UnArticle As Article In Liste
            ListeDesArticles_DTG.Rows.Add(UnArticle.Id.ToString, UnArticle.Designation, UnArticle.NNO, UnArticle.Quantite, UnArticle.QuantiteRecommande, UnArticle.Etat, UnArticle.Gisement, UnArticle.Emplacement, UnArticle.Installation)
        Next
    End Sub
Je remercie d'avance toutes personnes susceptible de m'aider.