I have a code that is running like this and calling an event.
The event is writing some lines to a textfile.
But after each loop, the event is writing one more line each time.

It seems that the += is filling the left side up.
Is there a way to delete the content on the left side of += after each loop ?

for (int i = 0; i < 3; i++)
{
      Fr->callEvent += gcnew Dt->callingEventHandler(this->callEvent );
}

Recommended Answers

All 5 Replies

>>Is there a way to delete the content on the left side of += after each loop ?

Can't know for sure without knowing Fr->callEvent type, but
Assumming callEvent is a string ? You can just reset it

for (int i = 0; i < 3; i++)
{
      Fr->callEvent = "";
      Fr->callEvent += gcnew Dt->callingEventHandler(this->callEvent );
}

Thanks,

The type is an event when looking at the properties, so the "" does not seem to work in this case.

When I try to write this in the compiler:

Fr->callEvent =

The intellisense says:
"The event callEvent can only appear on the left side of += or -="

This leaves my wondering if it would be possible to use -= to decrease after each loop in any way ?

>>This leaves my wondering if it would be possible to use -= to decrease after each loop in any way ?

Try it. Put Fr->callEvent -= Fr->callEvent after the call to Dt->eventHandler.

>>This leaves my wondering if it would be possible to use -= to decrease after each loop in any way ?

Try it. Put Fr->callEvent -= Fr->callEvent after the call to Dt->eventHandler.

Yes the -= seemed to work to decrease it in the same way. Hope it is programatically correct to do so :)

Thank you.

Yes the -= seemed to work to decrease it in the same way. Hope it is programatically correct to do so :)

It is :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.