PC Review


Reply
Thread Tools Rate Thread

Custom button from a Control class doesn't appear as a choice for OK/Cancel button in a Form properties

 
 
CroDude
Guest
Posts: n/a
 
      28th Jun 2005
Hi all!
I've made a button from scratch derived from a Control class. The main
reason why Control and not Button class is used for inheritance is that when
deriving from a control class it's possible to have a transparent
background, while if derived from a button class it isn't.
That's achieved through:
SetStyle(ControlStyles.SupportsTransparentBackColor, true);

But the problem appears when I place my buttons on a form and try to set
them as a OK/Cancel buttons. It seems that a form can't recognize my buttons
when I want to choose them as OK/Cancel button of a Form.
Is there something that I'm missing? Please help!

Thanks in advance!
Dinko Pavicic


 
Reply With Quote
 
 
 
 
Tim Wilson
Guest
Posts: n/a
 
      28th Jun 2005
Implement the IButtonControl interface in your custom control.

--
Tim Wilson
..Net Compact Framework MVP

"CroDude" <(E-Mail Removed)> wrote in message
news:d9q38j$srb$(E-Mail Removed)...
> Hi all!
> I've made a button from scratch derived from a Control class. The main
> reason why Control and not Button class is used for inheritance is that

when
> deriving from a control class it's possible to have a transparent
> background, while if derived from a button class it isn't.
> That's achieved through:
> SetStyle(ControlStyles.SupportsTransparentBackColor, true);
>
> But the problem appears when I place my buttons on a form and try to set
> them as a OK/Cancel buttons. It seems that a form can't recognize my

buttons
> when I want to choose them as OK/Cancel button of a Form.
> Is there something that I'm missing? Please help!
>
> Thanks in advance!
> Dinko Pavicic
>
>



 
Reply With Quote
 
Mick Doherty
Guest
Posts: n/a
 
      28th Jun 2005
It is possible to have transparency when inheriting from the button class.
As well as setting SupportsTransparentBackColor to true you must set Opaque
to False.

I wrote a button inherited from button a while back and posted the code on
my site.
http://dotnetrix.co.uk/buttons.html
There were a few obstacles to overcome so you may like to just borrow the
code and provide your own paint methods, but as Tim said, Implementing
IButtonControl on your current control should do the trick.

--
Mick Doherty
http://dotnetrix.co.uk/nothing.html


"Tim Wilson" <TIM(UNDERSCORE)WILSON(AT)ROGERS(PERIOD)COM> wrote in message
news:%(E-Mail Removed)...
> Implement the IButtonControl interface in your custom control.
>
> --
> Tim Wilson
> .Net Compact Framework MVP
>
> "CroDude" <(E-Mail Removed)> wrote in message
> news:d9q38j$srb$(E-Mail Removed)...
>> Hi all!
>> I've made a button from scratch derived from a Control class. The main
>> reason why Control and not Button class is used for inheritance is that

> when
>> deriving from a control class it's possible to have a transparent
>> background, while if derived from a button class it isn't.
>> That's achieved through:
>> SetStyle(ControlStyles.SupportsTransparentBackColor, true);
>>
>> But the problem appears when I place my buttons on a form and try to set
>> them as a OK/Cancel buttons. It seems that a form can't recognize my

> buttons
>> when I want to choose them as OK/Cancel button of a Form.
>> Is there something that I'm missing? Please help!
>>
>> Thanks in advance!
>> Dinko Pavicic
>>
>>

>
>



 
Reply With Quote
 
CroDude
Guest
Posts: n/a
 
      28th Jun 2005
Thank's a lot guys! That helped!


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cancel button doesn't delete the autosaved record from table abrown Microsoft Access Forms 2 23rd Aug 2008 04:44 AM
putting custom control on a form that inherits from my form class, doesn't work Capital O Microsoft Dot NET Compact Framework 2 4th Jan 2006 05:36 PM
IMPORTANT! 2.0 Login Control Has No Cancel Button clintonG Microsoft ASP .NET 14 29th Sep 2005 08:34 PM
IMPORTANT! 2.0 Login Control Has No Cancel Button clintonG Microsoft C# .NET 0 28th Sep 2005 02:32 AM
How to Close Form using a custom button control. =?Utf-8?B?VmVybg==?= Microsoft C# .NET 2 5th May 2005 07:20 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:49 AM.