473,398 Members | 2,165 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,398 software developers and data experts.

Custom Button Control

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 form and I set the
ButtonType property, all the fields that are changed are then highlighted as
changed and written in the Form.Designer.vb file to initialize those
properties. How can I prevent this from happening?

At the moment, the following is written:
Me.DialogButton1.Location = New System.Drawing.Point(359, 133)
Me.DialogButton1.Cursor = System.Windows.Forms.Cursors.Hand
Me.DialogButton1.ButtonType = ButtonTypeEnum.Arrow_Next
Me.DialogButton1.Font = New System.Drawing.Font("Tahoma", 9.0!)
Me.DialogButton1.Image =
CType(resources.GetObject("DialogButton1.Image"), System.Drawing.Image)
Me.DialogButton1.ImageAlign =
System.Drawing.ContentAlignment.MiddleRight
Me.DialogButton1.MaximumSize = New System.Drawing.Size(90, 28)
Me.DialogButton1.MinimumSize = New System.Drawing.Size(90, 28)
Me.DialogButton1.Size = New System.Drawing.Size(90, 28)
Me.DialogButton1.Text = "&Next "
Me.DialogButton1.TextAlign = ContentAlignment.MiddleRight
Me.DialogButton1.TextImageRelation =
TextImageRelation.TextBeforeImage
Me.DialogButton1.Name = "DialogButton1"
Basically most of those properties are already set when the control is
created or when the ButtonType property is set. So basically all I want to
appear in the form designer is:

Me.DialogButton1.Location = New System.Drawing.Point(359, 133)
Me.DialogButton1.ButtonType = ButtonTypeEnum.Arrow_Next
Me.DialogButton1.Name = "DialogButton1"
Any ideas how I can do that?

Regards

Wimpie
Jun 3 '07 #1
1 2471
Wimpie van Lingen wrote:
What happens is that when I put the control on a form and I set the
ButtonType property, all the fields that are changed are then highlighted as
changed and written in the Form.Designer.vb file to initialize those
properties. How can I prevent this from happening?
Welcome to the Wonderful World of Attributes.

To prevent the properties being considered as "changed" (and, therefore,
showing up as Bold), apply a DefaultValueAttribute to them (you may need
to override/shadow each Property before you can do this):

Imports System.ComponentModel

<DefaultValue("&Next")_
Property Text() as String
If you want to prevent the property appearing in the properties window
at all, then you can do that too.

<Browsable(False)_
Property Text() as String

*But* the Designer will /still/ write the code to set this property.
If you want to prevent this (and, IMHO, this is a Good Idea while you're
still developing your inherited Control), use this Attribute to tell it
not to:

<DesignerSerializationVisibility(DesignerSerializa tionVisibility.Hidden))_
Property Text() as String

So you wind up with combinations like this - for the stuff other
Developers can play with ...

<Browsable(True) _
, Category("Whizzo Stuff") _
, DefaultValue("(None)") _
, DesignerSerializationVisibility(Visible) _
Property Text() as String

.... and ...

<Browsable(False) _
, Category("Hidden Stuff") _
, DefaultValue("Some Value") _
, DesignerSerializationVisibility(Hidden) _
Property HiddenP() as String

HTH,
Phill W.
Jun 4 '07 #2

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

Similar topics

1
by: Robert Neville | last post by:
I am having some trouble with some old code revolving around custom form navigation buttons. My main form has a sub-form with these custom navigation buttons. In other words, the code should be...
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 have created a custom control button which when clicked displays a message in the JavaScript alert dialog. I could successfully compile the VB class file into a DLL & also could add it to 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'...
11
by: Pete Kane | last post by:
Hi All, does anyone know how to add TabPages of ones own classes at design time ? ideally when adding a new TabControl it would contain tab pages of my own classes, I know you can achieve this with...
15
by: rizwanahmed24 | last post by:
Hello i have made a custom control. i have placed a panel on it. I want this panel to behave just like the normal panel. The problem i was having is that the panel on my custom control doesnt...
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...
4
by: =?Utf-8?B?UmljaEI=?= | last post by:
I am trying to create a project using the ASP.NET AJAX accordion control. I would like to dynamically add panes to the control with a form template added when the pane is added. I have tried...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
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...
0
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...

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.