Solved

Remove Item from class object

Posted on 2012-03-11
2
272 Views
Last Modified: 2012-03-11
I have a Class which is declared as:

Imports System.ComponentModel

Public Class PendingDel
    Implements INotifyPropertyChanged
#Region "INotifyPropertyChanged Members"

    Public Event PropertyChanged As PropertyChangedEventHandler _
       Implements INotifyPropertyChanged.PropertyChanged

    Private Sub OnPropertyChanged(propertyName As String)
        RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(propertyName))

    End Sub

#End Region

Private m_JobNum As String
    Public Property JobNum As String
        Get
            Return m_JobNum
        End Get
        Set(value As String)
            If Me.m_JobNum <> value Then
                Me.m_JobNum = value
                Me.OnPropertyChanged("JobNum")
            End If
        End Set
    End Property

Private m_Driver As String
    Public Property Driver() As String
        Get
            Return Me.m_Driver
        End Get
        Set(value As String)
            If Me.m_Driver <> value Then
                Me.m_Driver = value
                Me.OnPropertyChanged("Driver")
            End If
        End Set
    End Property
End Class

I have declared a new collection at class level
Public Shared itemsSource As New ObservableCollection(Of Object)()

I am adding new items to the class using:
Public Sub loadDriverJobs()
        itemsSource.Add(New PendingDel() With { _
                             .JobNum = 1, _
                             .Driver = "Bob"})
        itemsSource.Add(New PendingDel() With { _
                             .JobNum = 2, _
                             .Driver = "Ian"})
    End Sub

How would I remove the JobNum 2 from the class, I have looked at different examples but can’t find how to achieve this, any help would be appreciated.
0
Comment
Question by:JoeBo747
2 Comments
 
LVL 5

Accepted Solution

by:
Aruiz04 earned 500 total points
ID: 37708191
itemsSource.RemoveAt(1)
0
 
LVL 1

Author Closing Comment

by:JoeBo747
ID: 37708314
Thanks for the reply, I was querying the itemsSource and attempting to remove the item via the returned records! Couldn’t spot the obvious!
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question