Button

J

Josh Booth

Hi,

Why when I create my own control inherited from System.Windows.Forms.Button
and overide the OnPaint function does the design time stuff work perfectly
but no matter what I do it has no effect when I deploy it?

Any help aprreciated.
regards
Josh
 
M

Maarten Struys

The problem you are encountering has to do with the fact that during design
time you are making use of the full .NET Framework, which supports OnPaint.
Unfortunately when you deploy to the device you are making use of the .NET
Compact Framework which, in the case of Buttons does allow you to overwrite
OnPaint. The Paint event is simply not published for further processing in
your application. To overcome this you would have to write your own Button,
derived from Control. There are more situations where during design time it
appears that there are events for controls available, which actually are not
implemented for the .NET CF.
 
N

Neil Cowburn [MVP]

Of course, Maarten intended to say that Buttons do NOT allow you to override
the OnPaint event. It is true that you must "roll your own" button, which is
fairly simple, to be honest.

If you need an example, let me know

HTH
Neil

--
Neil Cowburn
Microsoft Windows Embedded MVP

www.opennetcf.org
 
J

Josh

Yeah I gathered he meant not :)
What other controls have similar pitfalls? I wanted to overide DataGrid to
have some kind of double click effect, I think I'd have to do this with a
bool and a timer? Is that going to be possible?

DataGrid seems frustratingly limited to me has any body reimplemented it
with colum sorts, double clicks and so that clicking in a grey area doesnt
have an effect?
 
M

Maarten Struys

I tried to give some sort of an explanation why intellisense indicates there
is a Paint event available for a button, so it would be easy to assume that
you could overwrite OnPaint. I realize that I did not do the best job though
:).

--
Regards,

Maarten Struys
PTS Software bv
 
C

Chris Tacke, eMVP

*All* other controls except Control and Panel have this limitation.

-Chris
 

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