473,498 Members | 310 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Set Default Value for custom type

2 New Member
Hello!
I Have a class:

Expand|Select|Wrap|Line Numbers
  1. public class DoubleColor
  2. {
  3.     private color _Color1;
  4.     public color Color1 
  5.     {
  6.          get { return _Color1; }
  7.          set { _Color1=value; }
  8.     }
  9.  
  10.     private color _Color2;
  11.     public color Color2 
  12.     {
  13.          get { return _Color2; }
  14.          set { _Color2=value; }
  15.     }
  16. }
  17.  
  18. And another class:
  19. public class Class2:Control
  20.     private DoubleColor _MyColors;
  21.     public DoubleColor ProblemDirective
  22.     {
  23.          get { return _MyColors; }
  24.          set { _MyColors=value; }
  25.     }
  26. }
How can I set default value to ProblemDirective?
Like this
[DefaultValue(typeof(DoubleColor),?????????)]
Oct 12 '12 #1
3 2090
Rabbit
12,516 Recognized Expert Moderator MVP
Use the constructor to set up your defaults.
Oct 12 '12 #2
MadBob
2 New Member
You are right! But value in constructor is not absolutely default value, because visual studio designer are create code in Form's.Designer.cs
like this:
doubleColor1.Color1 = System.Drawing.Color.Red;
doubleColor1.Color2 = System.Drawing.Color.Blue;
If ProblemDirective will have [DefaultValue], Form's.Designer.cs will not create code.It also is necessary for me.
Sorru for English. I need help!
Oct 13 '12 #3
Rabbit
12,516 Recognized Expert Moderator MVP
I don't understand what you just said.
Oct 14 '12 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
1704
by: Franz | last post by:
I would like to know if there is a list for default values of types (e.g. int, float, bool, System.Drawing.Color, String, etc)? Thanks. -- Franz Wong My C++ and C# Site (Traditional Chinese) :...
4
2556
by: CroDude | last post by:
I've made a custom groupbox control. Inside, as one of it's members is CSimpleGradient object. CSimpleGradient is a wrapper class for gradient usage. Basically it looks like that: public class...
0
1140
by: Darren Clark | last post by:
I am trying to set the default value (not mistaken for NULL value) for a datetime element of a typed dataset. <xs:element name="create_date" type="xs:dateTime"...
7
4730
by: John Grandy | last post by:
My ASP.NET Web Service project has a Web Method that returns an array filled with instances of a custom class. The custom class is defined in a Class Library that is included in the web-service...
21
8707
by: planetthoughtful | last post by:
Hi All, As always, my posts come with a 'Warning: Newbie lies ahead!' disclaimer... I'm wondering if it's possible, using raw_input(), to provide a 'default' value with the prompt? I would...
4
10823
by: veerleverbr | last post by:
Suppose having define an enum like this: public enum SomeEnum { Something, SomethingElse }
0
1407
by: Rajesh | last post by:
I am trying to use a simple custom type for saving the profile information of a user. The custom class inherits from the Hashtable. I am serializing the type as "Binary" in the provider sections of...
4
3545
by: Macneed | last post by:
i am a newbie, i remember i read a book talking about when u declare a array variable using float ABC = new float; the whole array element in ABC ( ABC to ABC ) will automatic initialize to 0...
11
10081
by: =?Utf-8?B?bWljaGFlbCBzb3JlbnM=?= | last post by:
I have worked with application settings in VS2005 and C# for awhile, but usually with standard types. I have been trying to store a custom container/class/type in an application setting and I have...
1
1092
by: shapper | last post by:
Hello, I have two properties in a custom control. One is of a boolean type and the other is an enum type. How can I define a default value when they are not defined? Here is my code: ...
0
6998
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
7163
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
7200
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...
1
6884
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
7375
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
5460
agi2029
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,...
0
3090
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...
0
3078
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
287
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...

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.