Is there any way to set an event handler without doing it manually in the classname.designer.cs file other than double clicking the UI element?
views:
111answers:
3
+2
A:
If I follow your question correctly, you can just do it in your code-behind like this:
myButton.Click += myHandler;
Or you could use an anonymous delegate:
myButton.Click += delegate
{
MessageBox.Show("Clicked!");
};
HTH, Kent
Kent Boogaart
2008-11-21 19:02:29
+1
A:
Sure. Use myControl.Event += new EventHandler(SomeHandlerMethodInYourClass)
somewhere during initialization, e.g. in the form's constructor.
Dan C.
2008-11-21 19:02:56
+2
A:
Click on the lightning bolt icon in the Properties window. Double-click the event you want to implement.
Hans Passant
2008-11-23 14:18:47