CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2006
    Posts
    3

    EventHandlers (stupid question)

    Okay, this is probably a really dumb question but how do i manually modify what function is called in an event handler an not have Visual Studio change it back automatically after i compile next time? I went to the automatically generated code and just changed the function but VS just switches it back to whatever it originally placed there..

  2. #2
    Join Date
    Mar 2000
    Posts
    114

    Re: EventHandlers (stupid question)

    I'm not sure I understand the question, but you can manually add a callback to e.g. a buttons click by adding a line line like this

    button.Click += new EventHandler(OnClick);

    This has to be added after InitializeComponent is called.

    Then you have to implement a

    private void OnClick(object sender, EventArgs e)
    {
    }

    and you are done.

    Jesper

  3. #3
    Join Date
    Jul 2002
    Location
    India
    Posts
    505

    Re: EventHandlers (stupid question)

    Change the event handler using the properties window in designer mode.

    or

    remove the event handler line from InitializeComponent and put it in form load and then make the change.

    -Satish

  4. #4
    Join Date
    Mar 2006
    Posts
    3

    Re: EventHandlers (stupid question)

    Ah i didn't think to do that, i just added the eventhandler on load.. everything is peachy now. Thanks

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

Featured