Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Collections
Message
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Titre:
Divers
Thread ID:
00838904
Message ID:
00838970
Vues:
27
OK, thanks Cathi ... I *did* use a code converter since I'm not up on VB.NET. I wonder why they don't fix that so that it converts the code correctly.

>Hi Bonnie,
>
>One small change in the VB.NET code you provided. When handling events, VB.NET has different syntax then C#. The code inside of the collection should use the AddressOf. The code converters typically get this wrong.
>
>
>' This code is in your collection:
>
>' Create an EventHandler as you always do
>' to handle the Event.
>AddHandler Me.MyCollection.MyItems.ItemChanged, AddressOf Me.MyItems_ItemChanged
>
> ' and the EventHandler
>Protected Sub MyItems_ItemChanged(sender As Object, e As System.EventArgs)
>' code here
>End Sub 'MyItems_ItemChanged
>
>
>
>>>If my ItemClass has a Value set and get property
>>>
>>>How do i make the collection of the ItemClass know when the value property changed.
>>
>>OK, sorry, I misunderstood the question (I need some coffee <g>).
>>
>>Anyway, you'll need to create an Event.
>>
>>
>>' This code is in your ItemClass:
>>
>>' In your declarations
>>Event ItemChanged As EventHandler
>>
>> 'In your Item Property's Set() method
>>Me.OnItemChanged(New EventArgs())
>>
>> 'And the actual EventHandler method would be:
>>Protected Overridable Sub OnItemChanged(e As EventArgs)
>>   If Not (ItemChanged Is Nothing) Then
>>      ItemChanged(Me, e)
>>   End If
>>End
>>
>>
>> ' This code is in your collection:
>>
>>' Create an EventHandler as you always do
>>' to handle the Event.
>>Me.MyCollection.MyItems.ItemChanged += New System.EventHandler(Me.MyItems_ItemChanged)
>>
>> ' and the EventHandler
>>Protected Sub MyItems_ItemChanged(sender As Object, e As System.EventArgs)
>>' code here
>>End Sub 'MyItems_ItemChanged
>>
>>
>>~~Bonnie
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform