473,569 Members | 2,601 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(Contro lStyles.Support sTransparentBac kColor, 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 1726
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.h r...
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(Contro lStyles.Support sTransparentBac kColor, 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 SupportsTranspa rentBackColor 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)ROGE RS(PERIOD)COM> wrote in message
news:%2******** ********@TK2MSF TNGP10.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.h r...
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(Contro lStyles.Support sTransparentBac kColor, 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
4760
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 Handler class and use that, but I would like to use the System.EventArgs class so that my event can be handled by different controls. For...
0
1852
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 2003, although I'm not sure what is actually causing the problem. I can't summarize the issue, so please read on to find out more. I've created a...
4
6062
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 of a Custom User Control, generated by adding a new Custom User Control to a project with VS.NET.
19
4900
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 exception of custom Collection Classes. Background: I'm developing an A2K .mdb to be deployed as an .mde at my current job-site. It has several custom...
1
3202
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' & 'Cancel'). Till this point, no problem. Initially, the TextBox is empty. The Button has a property named 'ConfirmMessage' so that the developer using this...
0
1383
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' buttons. If the user clicks 'OK', the TextBox gets populated with 'true' & if 'Cancel' is clicked, the TextBox gets populated with 'false'. Note that...
1
2479
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 property changes, the Image, Text, TextAlignment, etc. properties are changed for the control. What happens is that when I put the control on a...
2
19426
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 will be writing this article intended for those who are in the same level, or maybe lower, of my technical knowledge. I would be using layman's...
0
2897
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 will be writing this article intended for those who are in the same level, or maybe lower, of my technical knowledge. I would be using layman's...
0
8130
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7979
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5514
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5219
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3653
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3643
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2115
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1223
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
940
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.