473,396 Members | 1,599 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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

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.SupportsTransparentBackColo r, 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
Nov 17 '05 #1
3 1719
Implement the IButtonControl interface in your custom control.

--
Tim Wilson
..Net Compact Framework MVP

"CroDude" <di***********@zg.htnet.hr> wrote in message
news:d9**********@news1.xnet.hr...
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.SupportsTransparentBackColo r, 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

Nov 17 '05 #2
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:%2****************@TK2MSFTNGP10.phx.gbl...
Implement the IButtonControl interface in your custom control.

--
Tim Wilson
.Net Compact Framework MVP

"CroDude" <di***********@zg.htnet.hr> wrote in message
news:d9**********@news1.xnet.hr...
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.SupportsTransparentBackColo r, 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


Nov 17 '05 #3
Thank's a lot guys! That helped!
Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Steve Amey | last post by:
Hi all I am creating a basic control to perform some tasks, and I want to declare some events to be raised so they can be handled from the form that the control is on. I can create my own Event...
0
by: Dave | last post by:
Hi everyone, (I already posted this to the VS.NET IDE news group without any responses, so I'm attempting one more time in this group) The issue I'm having is occuring in the IDE of VS.NET...
4
by: Paradox | last post by:
Hey, I'm trying to figure out what situations call for the use of a derived form control such as: public class myListBox : System.Windows.Forms.ListBox and what situations call for the use...
19
by: Jamey Shuemaker | last post by:
I'm in the process of expanding my knowledge and use of Class Modules. I've perused MSDN and this and other sites, and I'm pretty comfortable with my understanding of Class Modules with the...
1
by: rn5a | last post by:
I want to create a custom control that encapsulates a Button & a TextBox. When the Button is clicked, the user is asked a question using JavaScript confirm (which shows 2 buttons - 'OK' &...
0
by: rn5a | last post by:
A custom control is derived from the WebControl class & encapsulates a TextBox & a Button. When the Button is clicked, the user is shown the JavaScript confirm dialog with the 'OK' & 'Cancel'...
1
by: Wimpie van Lingen | last post by:
Hi I've created a control that inherits from the button control. The control has one additional property called ButtonType which can be set to Ok, Cancel, New, Edit, etc. When the ButtonType...
2
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
0
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.