CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 1999
    Location
    Slovenia
    Posts
    50

    Add EventHandler

    Hi all!

    I'm a begginer in C#.
    I want to know how add events on control, for exaple:

    I have DataGrid and i want add event OnDoubleClick().
    Is there wizard like in Visual Studio 6.
    I add on hands

    this.datagrid.DoubleClick+= new System.EventHandler(this.OnDoubleClickDG);
    ...
    protected void OnDoubleClickDG(EventArgs e)
    {}

    But i get an error

    TNX for help

    Marry Christmas

  2. #2
    Join Date
    Dec 2000
    Location
    Slovakia
    Posts
    1,043
    System.EventHandler c-tor takes two parameters. The first one is of type object, the second one is EventArgs. So rewrite your OnDoubleClickDG function:
    Code:
    protected void OnDoubleClickDG(object sender, EventArgs e);
    {
        // Implementation
    }
    Regarding the other question about the wizards:
    When you select your control in Visual Studio designer, go to the properties window. There is icon (something as lightning). Click on it and the content of the window changes to the events... You can select event there...

    Martin

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