On Sun, 28 Sep 2008 16:43:00 -0700, RRJ <RR*@discussions.microsoft.com>
wrote:
Hello,
I would like to add the Paint handler to the form. How to do it?
What do you mean? Do you mean you have an event handler that you want
subscribed to a form's Paint event? Or do you mean you have a form's
Paint event and you want to write an event handler for it?
In either case, there are ways to do it using the IDE and doing it
manually.
Subscribe an event handler:
-- Using the IDE, choose the "Events" list in the form's Properties
window, find the Paint event, click in the edit area and a drop-down
showing all eligible handlers in the container will be shown (in this
case, that's likely to just be the form)
-- Doing it manually, simply use the C# event add syntax. For
example, where the handler method's name is "MyPaintHandler":
Form form = ...; // your initialization goes here
form.Paint += MyPaintHandler;
Write an event handler:
-- Using the IDE, as above for subscribing a handler, but double-click
in the edit area instead. A new handler will be inserted in the relevant
container class, to which you can add whatever code you want.
-- Doing it manually, just write the event handler method, ensuring
that the signature for the method is correct. For the Paint event, you
need a method that looks like this:
void MyPaintHandler(object sender, PaintEventArgs e)
{
}
Pete