Adding events to usew windows controls

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Vicky

    Adding events to usew windows controls

    I created a windows control. I need to define the event for a button
    in it at the time i use it in apllications. I used the code below:


    public event MouseEventHandl er OkClick
    {
    add
    {
    button1.Click += value;
    }
    remove
    {
    button1.Click -= (MouseEventHand ler)value;
    }
    }

    But it is giving error that 'EverHadler' type cannot be implicitly
    converted to 'MouseEventHand ler'. Can someone tell me how to do it?
  • Family Tree Mike

    #2
    Re: Adding events to usew windows controls

    You don't need a MouseEventHandl er, so change it to:

    public event EventHandler OkClick
    {
    add
    {
    button1.Click += value;
    }
    remove
    {
    button1.Click -= value;
    }
    }

    "Vicky" <vicky87.eie@gm ail.comwrote in message
    news:3e08f0c7-c2ac-4db9-ae3f-7ccaeecc0481@b3 8g2000prf.googl egroups.com...
    >I created a windows control. I need to define the event for a button
    in it at the time i use it in apllications. I used the code below:
    >
    >
    public event MouseEventHandl er OkClick
    {
    add
    {
    button1.Click += value;
    }
    remove
    {
    button1.Click -= (MouseEventHand ler)value;
    }
    }
    >
    But it is giving error that 'EverHadler' type cannot be implicitly
    converted to 'MouseEventHand ler'. Can someone tell me how to do it?

    Comment

    Working...