Results 1 to 6 of 6

Thread: Events in a usercontrol.

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jul 1999
    Posts
    207

    Events in a usercontrol.

    Ok,

    I have this code in a usercontrol
    PHP Code:
    public delegate void commandEntered();
    public static 
    event commandEntered doCommand
    but I don't seem to be able to see the event listed in the properties of the control from the form that it is contained on.

    Any ideas?
    Jeremy

  2. #2
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    whats the difference between a static event and a non-static event?
    \m/\m/

  3. #3
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    The way you attach to it.
    For a normal event you write
    Code:
    Button button = new Button();
    button.Click += new EventHandler(MyHandler);
    For a static event you write
    Code:
    Application.Idle += new EventHandler(MyHandler);
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  4. #4
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    In other words it's probably wrong to make events on a user control static.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  5. #5
    Addicted Member chander's Avatar
    Join Date
    Nov 2000
    Location
    New Delhi , India
    Posts
    225
    can some one explain me the whole procedure of declaring Event , adding event and raising the event .. in C# i mean some easy sample code , i had a look .Net help but its seemed bit confused as lot of topic included in tht .. i just want to declare and raise an event in my control .. can some one help ...
    Chander
    Email:[email protected]

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Jul 1999
    Posts
    207
    I think this is the way it goes.
    PHP Code:
    //define the delegate
    delegate void myDelegate();

    //define your event from your delegate
    event myDelegate myEvent

    //raise the event
    if (myEvent != null)
    {
        
    myEvent();


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width