PC Review
Forums
Newsgroups
Microsoft DotNet
Microsoft Dot NET Framework Forms
System.Collections.ObjectModel.KeyedCollection
Forums
Newsgroups
Microsoft DotNet
Microsoft Dot NET Framework Forms
System.Collections.ObjectModel.KeyedCollection
![]() |
System.Collections.ObjectModel.KeyedCollection |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
As an ASP.NET devloper dabbling in the world of WindowsForms I am stumped.
I have created a class and implemented INotifyPropertyChanged on each of the properties. I have then created a collection inheriting from KeyedCollection. My problem is I don't know how to consume the events raised by the items in the collection so I can set the collection's dirty flag. Can someone help please. Many thanks, Nick ********************************************************* Imports System.ComponentModel Public Class stsTrap Implements INotifyPropertyChanged Public Event PropertyChanged As PropertyChangedEventHandler Implements INotifyPropertyChanged.PropertyChanged Private Sub NotifyPropertyChanged(ByVal info As String) RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(info)) End Sub Private mstrOID As String Private mstrDesc As String Private mstrMib As String Private mintSeverity As Int16 = 1 Private mbIsDirty As Boolean = False Public Sub New() End Sub Public Property OID() As String Get Return mstrOID End Get Set(ByVal value As String) 'TODO - Do validation checks here If Not value.Equals(mstrOID) Then mstrOID = value mbIsDirty = True NotifyPropertyChanged("OID") End If End Set End Property Public Property Description() As String Get Return mstrDesc End Get Set(ByVal value As String) 'TODO - Do validation checks here. If Not value.Equals(mstrDesc) Then mstrDesc = value mbIsDirty = True NotifyPropertyChanged("Description") End If End Set End Property Public Property MIB() As String Get Return mstrMib End Get Set(ByVal value As String) 'TODO - Do validation checks here. If Not value.Equals(mstrMib) Then mstrMib = value mbIsDirty = True NotifyPropertyChanged("MIB") End If End Set End Property Public Property Severity() As Int16 Get Return mintSeverity End Get Set(ByVal value As Int16) If value < 1 Or value > 99 Then Throw New ArgumentOutOfRangeException("value", value, "Trap severity must be between 1 and 99") End If If Not value.Equals(mintSeverity) Then mintSeverity = value mbIsDirty = True NotifyPropertyChanged("Severity") End If End Set End Property End Class Public Class stsTraps Inherits System.Collections.ObjectModel.KeyedCollection(Of String, stsTrap) Private mbIsDirty As Boolean = False Protected Overrides Function GetKeyForItem(ByVal item As stsTrap) As String Return item.OID End Function Protected ReadOnly Property IsDirty() As Boolean Get Return mbisdirty End Get End Property End Class |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

