473,698 Members | 2,392 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.v b file to initialize those
properties. How can I prevent this from happening?

At the moment, the following is written:
Me.DialogButton 1.Location = New System.Drawing. Point(359, 133)
Me.DialogButton 1.Cursor = System.Windows. Forms.Cursors.H and
Me.DialogButton 1.ButtonType = ButtonTypeEnum. Arrow_Next
Me.DialogButton 1.Font = New System.Drawing. Font("Tahoma", 9.0!)
Me.DialogButton 1.Image =
CType(resources .GetObject("Dia logButton1.Imag e"), System.Drawing. Image)
Me.DialogButton 1.ImageAlign =
System.Drawing. ContentAlignmen t.MiddleRight
Me.DialogButton 1.MaximumSize = New System.Drawing. Size(90, 28)
Me.DialogButton 1.MinimumSize = New System.Drawing. Size(90, 28)
Me.DialogButton 1.Size = New System.Drawing. Size(90, 28)
Me.DialogButton 1.Text = "&Next "
Me.DialogButton 1.TextAlign = ContentAlignmen t.MiddleRight
Me.DialogButton 1.TextImageRela tion =
TextImageRelati on.TextBeforeIm age
Me.DialogButton 1.Name = "DialogButt on1"
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.DialogButton 1.Location = New System.Drawing. Point(359, 133)
Me.DialogButton 1.ButtonType = ButtonTypeEnum. Arrow_Next
Me.DialogButton 1.Name = "DialogButt on1"
Any ideas how I can do that?

Regards

Wimpie
Jun 3 '07 #1
1 2480
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.v b 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 DefaultValueAtt ribute to them (you may need
to override/shadow each Property before you can do this):

Imports System.Componen tModel

<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(Fals e)_
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:

<DesignerSerial izationVisibili ty(DesignerSeri alizationVisibi lity.Hidden))_
Property Text() as String

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

<Browsable(True ) _
, Category("Whizz o Stuff") _
, DefaultValue("( None)") _
, DesignerSeriali zationVisibilit y(Visible) _
Property Text() as String

.... and ...

<Browsable(Fals e) _
, Category("Hidde n Stuff") _
, DefaultValue("S ome Value") _
, DesignerSeriali zationVisibilit y(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
3549
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 modular and work across forms and sub-forms. My previous code was taken from the Access Expert Solutions 97 (Leszynski) many years ago. As my database became more complex with multiple sub-forms and intricate combo boxes, the code faltered. Some...
19
4910
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 controls which utilize custom classes to wrap built-in controls, and add additional functionality....
1
4801
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 Toolbox in Visual Web Developer 2005 Express Edition but the alert message isn't popping up when I am implementing this control in an ASP.NET page & clicking the Button in the ASPX page. This is the class file: Imports System Imports System.Web...
1
3225
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 custom control can modify the question in the confirm dialog. If the user clicks 'OK', I want the...
0
1389
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 when the user first comes to the ASPX page that uses this custom control, the TextBox is empty. This...
11
18124
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 ListView columns so it should be doable, thanks
15
6512
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 accept other controls. The control i drag drop on it becomes the child of my custom control's parent form and not the child of my custom control. Then i added this line "" before my custom control class (i dont know what this line does). Now
2
19474
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 words, or maybe, my own words as how I understand them, hoping, you will understand it the same way that...
4
2482
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 unsuccessfully in creating the whole pane as a user control and have succeeded in adding the pane and then dynamically adding the content which is a user control to the pane, dynamically within the page. However I would like to have a single pane...
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 words, or maybe, my own words as how I understand them, hoping, you will understand it the same way that...
0
8609
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9166
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9030
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8899
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
5861
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4621
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3052
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
2
2333
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2007
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.