Click to See Complete Forum and Search --> : Add EventHandler


Hambi
December 17th, 2002, 03:48 AM
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

MartinL
December 17th, 2002, 06:06 AM
System.EventHandler c-tor takes two parameters. The first one is of type object, the second one is EventArgs. So rewrite your OnDoubleClickDG function:

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