PaintEventHandler

S

shilpichaudhry

Following is a method of the Control class defined in
System.Windows.Forms

protected virtual void OnPaint(PaintEventArgs e)
{
if (this.CanRaiseEvents)
{
PaintEventHandler handler = (PaintEventHandler)
base.Events[EventPaint];
if (handler != null)
{
handler(this, e);
}
}
}

Paint EventHandler is a delegate defined as;

public delegate void PaintEventHandler(object sender, PaintEventArgs
e);


Where can I find the code for the above mentioned method :
PaintEventHandler?

Thanks, Shilpi
 
N

Nicholas Paldino [.NET/C# MVP]

Shilpi,

That's the thing, you can't. PaintEventHandler is a delegate, which
allows you to assign a method with the same signature to it, pass it around,
and have that method called somewhere else.

The primary use is for events, which is what you are looking at here.

That being said, there really is no code, just a structure that says
that methods with similar signatures can be assigned to it, to be called at
that or another time.
 
S

shilpichaudhry

Shilpi,

That's the thing, you can't. PaintEventHandler is a delegate, which
allows you to assign a method with the same signature to it, pass it around,
and have that method called somewhere else.

The primary use is for events, which is what you are looking at here.

That being said, there really is no code, just a structure that says
that methods with similar signatures can be assigned to it, to be called at
that or another time.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)




Following is a method of the Control class defined in
System.Windows.Forms
protected virtual void OnPaint(PaintEventArgs e)
{
if (this.CanRaiseEvents)
{
PaintEventHandler handler = (PaintEventHandler)
base.Events[EventPaint];
if (handler != null)
{
handler(this, e);
}
}
}
Paint EventHandler is a delegate defined as;
public delegate void PaintEventHandler(object sender, PaintEventArgs
e);
Where can I find the code for the above mentioned method :
PaintEventHandler?
Thanks, Shilpi- Hide quoted text -

- Show quoted text -

So what happens when OnPaint is called?
 
S

shilpichaudhry

Shilpi,

That's the thing, you can't. PaintEventHandler is a delegate, which
allows you to assign a method with the same signature to it, pass it around,
and have that method called somewhere else.

The primary use is for events, which is what you are looking at here.

That being said, there really is no code, just a structure that says
that methods with similar signatures can be assigned to it, to be called at
that or another time.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)




Following is a method of the Control class defined in
System.Windows.Forms
protected virtual void OnPaint(PaintEventArgs e)
{
if (this.CanRaiseEvents)
{
PaintEventHandler handler = (PaintEventHandler)
base.Events[EventPaint];
if (handler != null)
{
handler(this, e);
}
}
}
Paint EventHandler is a delegate defined as;
public delegate void PaintEventHandler(object sender, PaintEventArgs
e);
Where can I find the code for the above mentioned method :
PaintEventHandler?
Thanks, Shilpi- Hide quoted text -

- Show quoted text -

and also if you could suggest an alternative to my problem:
I have controls within a group that get clipped according to the size
of the groupbox, I don't want them to be clipped -
 
P

Peter Duniho

So what happens when OnPaint is called?

At run time, all the delegates attached to the handler at the time it was
copied to the local "handler" variable will be executed. Depending on
your code, you could do a search for code that adds itself to the Paint
event for the class, but the only truly reliable way to know what would be
executed is to break at that point in code and see what delegates have
been attached to the event.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top