buongiorno,

ho costruito queste due classi per gestire le manutenzioni di un mezzo...funziona alla grande, l'unico problema non capisco com'è possibile nonostante elimini l'oggetto un oggetto, l'immagine su disco precedentemente associata all'oggetto (classe) continua ad essere in uso dal programma fino a quando non chiudo completamente il programma..

gli oggetti sono contenuti da un List(of OggettoManutenzione) pubblico

Public Manutenzioni As New List(Of OggettoManutenzione)

queste le due classi, in particolare da prendere in cosiderazione la seconda che gestisce l'immagine (TipoImmagineMan):

codice:
Public Class OggettoManutenzione
    Class EventoManutenzione
        Private _KM As Long = Nothing
        Private _Data As Date = Nothing
        Private _Mesi As Long = Nothing
        Private _Nota As String = Nothing
        Private _Costo As Double
        Public Property KM As Long
            Get
                KM = _KM
            End Get
            Set(ByVal value As Long)
                _KM = value
            End Set
        End Property
        Public Property Data As Date
            Get
                Data = _Data
            End Get
            Set(ByVal value As Date)
                _Data = value
                _Mesi = Nothing
            End Set
        End Property
        Public Property Mesi As Long
            Get
                Mesi = _Mesi
            End Get
            Set(ByVal value As Long)
                _Mesi = value
                _Data = Nothing
            End Set
        End Property
        Public Property Nota As String
            Get
                Nota = _Nota
            End Get
            Set(ByVal value As String)
                _Nota = value
            End Set
        End Property
        Public Property Costo As Double
            Get
                Costo = _Costo
            End Get
            Set(ByVal value As Double)
                _Costo = value
            End Set
        End Property
        Sub Setta(ByVal KM As Long, ByVal Mesi As Long)
            _KM = KM
            _Mesi = Mesi
        End Sub

    End Class

    Private _ID As Long = 0
    Private Shared _Conta As Long = 0
    Private _Dettagli As String = Nothing
    Public Image As TipoImmagineMan = Nothing
    Private _Voce As String = Nothing
    Private _Manutenzioni As New List(Of EventoManutenzione)
    Private _Intervallo As New EventoManutenzione

    Public ReadOnly Property ID As Long
        Get
            ID = _ID
        End Get
    End Property
    Public Property Dettagli As String
        Get
            Dettagli = _Dettagli
        End Get
        Set(ByVal value As String)
            _Dettagli = value
        End Set
    End Property
    Public Property Voce As String
        Get
            Voce = _Voce
        End Get
        Set(ByVal value As String)
            _Voce = value
        End Set
    End Property
    Public Property Manutenzioni As List(Of EventoManutenzione)
        Get
            Manutenzioni = _Manutenzioni
        End Get
        Set(ByVal value As List(Of EventoManutenzione))
            _Manutenzioni = value
        End Set
    End Property
    Public Property Intervallo As EventoManutenzione
        Get
            Intervallo = _Intervallo
        End Get
        Set(ByVal value As EventoManutenzione)
            _Intervallo = value
        End Set
    End Property

    Sub New()
        _Conta += 1
        _ID = _Conta
    End Sub

End Class

Public Class TipoImmagineMan
    Private _Image As Image = My.Resources.NoImage
    Private _PosizImage As String = Nothing

    Public Property Image As Drawing.Bitmap
        Get
            Image = _Image
        End Get
        Set(ByVal value As Drawing.Bitmap)
            _Image = IIf(Not IsNothing(value), value, My.Resources.NoImage)
        End Set
    End Property
    Public Property Strings As String
        Get
            Strings = _PosizImage
        End Get
        Set(ByVal value As String)
            Image = TipoImmagineMan.GetImage(value)
            _PosizImage = value
        End Set
    End Property

    Shared Function GetImage(ByVal ImgPosiz As String) As Image
        Dim ImagePos As String = EstrapolaStringa(ImgPosiz, , ",")
        Dim ImageLink As String = EstrapolaStringa(ImgPosiz, ",")
        Try
            Select Case ImagePos
                Case "File"
                    Return System.Drawing.Image.FromFile(ImageLink)
                Case "Default" ' --> My.Resource
                    Return My.Resources.ResourceManager.GetObject(ImageLink)
                Case Else
                    Return Nothing
            End Select
        Catch ex As Exception
            Return Nothing
        End Try
    End Function

End Class
se non si capisce molto proverò a spiegare l'essenziale..
sono accettati anche consigli