Re: How to clone event handlers

Discussion in 'ASP .Net' started by Hamed, Aug 12, 2006.

  1. Hamed

    Hamed Guest

    If I just could copy the events, this would be enough for me.
     
    Hamed, Aug 12, 2006
    #1
    1. Advertisements

  2. Hamed

    Hamed Guest

    Nicholas

    The method that is creating the clone is a member of the class being cloned.
    I want for example to assign the Click event of the control of my own to the
    new cloned object. but when I tried your solution I got compiler error. for
    example:

    public class MyTextBox : TextBox, ICloneable
    {
    public object Clone()
    {
    MyTextBox clone = new MyTextBox();
    clone.Click += this.Click; //compiler error!
    The event '....Click' can only appear on the left hand side of += or -=
    }
    }

    Would you kindly describe your suggestion more?

    Best Regards
    Hamed


     
    Hamed, Aug 12, 2006
    #2
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.