Bashar wrote:
I should write the delegate like so:
Private Sub entity_EntityAdding(Of EventArgs)(ByVal sender As Object, ByVal e As CancelableCollectionChangedEventArgs)
No that's not correct, as that suggests EventHandler<EventArgs> is used (or better: EventHandler) in the class which raises the event, which isn't the case.
This seemed to solve the problem of (e.Cancel) but another error popped up:
'Type arguments for method 'Private Sub entityDetail_EntityAdding(Of EventArgs)(sender As Object, e As SD.LLBLGen.Pro.ORMSupportClasses.CancelableCollectionChangedEventArgs)' could not be inferred from the delegate 'Delegate Sub EventHandler(Of TEventArgs As System.EventArgs)(sender As Object, e As SD.LLBLGen.Pro.ORMSupportClasses.CancelableCollectionChangedEventArgs)'
Are you sure there isn't something wrong here?
this is the class:
/// <summary>
/// Event args which are used for collection changed events and which is raised by cancelable actions. Set the Cancel flag to cancel the action
/// which raised the event.
/// </summary>
public class CancelableCollectionChangedEventArgs : CollectionChangedEventArgs
{
#region Class Member Declarations
private bool _cancel;
#endregion
/// <summary>
/// Initializes a new instance of the <see cref="CancelableCollectionChangedEventArgs"/> class.
/// </summary>
/// <param name="involvedEntity">The involved entity.</param>
public CancelableCollectionChangedEventArgs( IEntityCore involvedEntity )
: base( involvedEntity )
{
}
/// <summary>
/// Gets / sets the cancel flag to cancel the action.
/// </summary>
public bool Cancel
{
get
{
return _cancel;
}
set
{
_cancel = value;
}
}
}
/// <summary>
/// EventArgs class for events raised by the entity collection classes for various actions.
/// </summary>
public class CollectionChangedEventArgs : EventArgs
{
#region Class Member Declarations
private IEntityCore _involvedEntity;
#endregion
/// <summary>
/// Initializes a new instance of the <see cref="CollectionChangedEventArgs"/> class.
/// </summary>
/// <param name="involvedEntity">The involved entity.</param>
public CollectionChangedEventArgs( IEntityCore involvedEntity )
{
_involvedEntity = involvedEntity;
}
/// <summary>
/// Gets / sets the entity involved in the action which took place and which triggered the raised event.
/// </summary>
public IEntityCore InvolvedEntity
{
get
{
return _involvedEntity;
}
set
{
_involvedEntity = value;
}
}
}
Cancel is there. (v2.0, .NET 2.0 code base)
The original method declaration you had in the first post is correct, what I find strange is that the Cancel property isn't accessable.
you could try as well:
Private Sub entity_EntityAdding(ByVal sender As Object, ByVal e As CancelableCollectionChangedEventArgs)
as the generic type specification is implicit anyway