OnPaint is not called in subclassed button control

G

Guest

Hello all.

I have created a control that subclasses Windows.Forms.Button.

I need to override the OnPaint method, in order to draw an image instead of
text. However, my OnPaint override is never called!

protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint (e);

if (m_oImage != null)
{
//Code that pains Image ...
}
}

Any clues;

PS : I do not want to use OpenNetCF ButtonEx. I just need to add image
painting on the button and not all the other functionality ButtonEx provides.
 
T

Tim Wilson

The information at the links below should help.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetcomp/html/ImageButton.asp
http://samples.gotdotnet.com/quickstart/CompactFramework/doc/picturebutton.aspx

--
Tim Wilson
..NET Compact Framework MVP

Strider said:
Hello all.

I have created a control that subclasses Windows.Forms.Button.

I need to override the OnPaint method, in order to draw an image instead of
text. However, my OnPaint override is never called!

protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint (e);

if (m_oImage != null)
{
//Code that pains Image ...
}
}

Any clues;

PS : I do not want to use OpenNetCF ButtonEx. I just need to add image
painting on the button and not all the other functionality ButtonEx
provides.
 

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