I'm writing my own control that derived from the UserControl.
In my control I have some public properties (with get and set) that I do not
want them to be shown on the designer properties window and I also do not
want the Windows Form Designer to generate code automatically on the user
Form for them.
To block the properties from being shown on the designer properties window I
use:
[System.Componen tModel.Browsabl e(false)]
public int MyProp
{
get { return m_int; }
get { m_int = value; }
}
But I could not find how to prevent the Windows Form Designer from
generating code automatically on the user Form.
Can anybody help me with that?
--------
Thanks
Sharon 7 2633
You could try adding a System.Componen tModel.DefaultV alueAttribute - i.e.
[DefaultValue(0)]; according to http://msdn.microsoft.com/library/de...lasstopic.asp:
"A visual designer can use the default value to reset the member's value.
Code generators can use the default values also to determine whether code
should be generated for the member."
Marc
"Sharon" <Sh*****@newsgr oups.nospam> wrote in message
news:E9******** *************** ***********@mic rosoft.com... I'm writing my own control that derived from the UserControl. In my control I have some public properties (with get and set) that I do not want them to be shown on the designer properties window and I also do not want the Windows Form Designer to generate code automatically on the user Form for them.
To block the properties from being shown on the designer properties window I use: [System.Componen tModel.Browsabl e(false)] public int MyProp { get { return m_int; } get { m_int = value; } }
But I could not find how to prevent the Windows Form Designer from generating code automatically on the user Form.
Can anybody help me with that?
-------- Thanks Sharon
No, it's does not work, at least not for properties that are of class/struct
types.
Any idea?
--
Thanks
Sharon
(throws open the floor to other takers...)
"Sharon" <Sh*****@newsgr oups.nospam> wrote in message
news:30******** *************** ***********@mic rosoft.com... No, it's does not work, at least not for properties that are of class/struct types.
Any idea?
-- Thanks Sharon
What information is automatically being generated for the property you
specified?
I ask because Marc's suggestion should have worked.
Dave
Try this:
using System.Componen tModel;
[DesignerSeriali zationVisibilit y(DesignerSeria lizationVisibil ity.Hidden),
Browsable(false )]
public int MyProp
{
get { return m_int; }
get { m_int = value; }
}
Jesse
Ok, I have a field:
private Point m_imgOrigin = Point.Empty
And a property for it:
[Browsable(false ), DefaultValue(nu ll)]
public Point ImageOrigin
{
get { return m_imgOrigin; }
set { m_imgOrigin = value; }
}
And the Windows Form Designer generates the following code automatically:
this.m_map.Imag eOrigin = new System.Drawing. Point(0, 0);
But I do not want the Form designer to generate any code for it.
But Jesse suggestion is working:
[DesignerSeriali zationVisibilit y(DesignerSeria lizationVisibil ity.Hidden),
Browsable(false )]
------
Thanks
Sharon
Thank Jesse, thais is the one.
It works!
------
Thanks
Sharon This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: james |
last post by:
I cannot get my UserControl's browsable properties to show up
in the designer properties panel.
I have
then public virtual bool TestProp { {get return testProp; } set { testProp =
value; } }
but it doesn't show up in the designer. By the way, this used to
work in the 2002 version, now in 2003 I am getting all kinds
of problems like this
|
by: Tiago Barbutti |
last post by:
I have a UserControl that execute methods in Load event,
but it hapens in designMode and generate an error and the
control disappear from the form.
I read that i can use the DesignMode to kwnow when my
control is in design or Runtime mode, it´s work, but when
this usercontrol is put in another usercontrol the
DesignMode property always return false.
How can I do to stop the methods to execute in
designMode when my usercontrol is in...
|
by: Tony Maresca |
last post by:
Hi. I have a class derived from a UserControl,
that I want to allow others to derive controls
from. I don't want them to design the base
class (which is derived from a UserControl).
I know that I can prevent the control from being
designed by making it not the first class in the
code file, but is there another more 'official' way
to do this via attributes.
|
by: Fabio Cannizzo |
last post by:
How can I prevent a few lines of code contained in the constructor of a Form
from being executed by the Designer?
Thanks,
Fabio
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
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,...
|
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...
|
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...
|
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,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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...
| |