473,396 Members | 1,826 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,396 software developers and data experts.

HOW TO: Set a DefaultValueAttribute to system color?

Hey guys! :O)

i'd like to know how would one set a default color property to a system
color ?

as you might guess, this code doesn't work ...
//***
[DefaultValue((object)Color.FromKnownColor(KnownCol or.Window))]
public void MyProp
{
//....
}
//***

thanks in advance!

--
Best Regards
Yanick Lefebvre
Nov 16 '05 #1
2 7507
Zoury,

You will want to declare your attribute like this:

[DefaultValue(typeof(Color), "ControlText")]

This above line will have the designer look for the Color type. When it
gets it, it will look for the TypeConverter attribute on the type to
indicate what TypeConverter to use. Once it gets that, it will pass the
string "ControlText" to the ConvertFromString method to get the color to
actually use.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Zoury" <ya*************@hotmail.com> wrote in message
news:Oh**************@tk2msftngp13.phx.gbl...
Hey guys! :O)

i'd like to know how would one set a default color property to a system
color ?

as you might guess, this code doesn't work ...
//***
[DefaultValue((object)Color.FromKnownColor(KnownCol or.Window))]
public void MyProp
{
//....
}
//***

thanks in advance!

--
Best Regards
Yanick Lefebvre

Nov 16 '05 #2
Neat! Thanks Nicholas! ;O)

--
Best Regards
Yanick Lefebvre
Nov 16 '05 #3

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

Similar topics

3
by: Terrence | last post by:
I am doing some of the C# walkthroughs to transition from VB to C#. When I try to execute static void Main() { Aplication.Run(new Form1()) } I raise a 'System.NullReferenceException" in...
2
by: Scott | last post by:
Not sure if this is the right place to post this or not, but I am in the process of trying to find a Web Hosting/Isp Billing system that is reasonable in price and uses Access or SQL Server for a...
0
by: Gianluca | last post by:
Properties of inherited controls have the default value set to the value that is assigned in the InitializeComponent method in the base form class. Which is correct and useful. In the derived form...
3
by: Homa | last post by:
I've create a custom DataGridColumnStyle and when I try to assign a DefaultValue to a property, it doesn't seems to have any effect. Here is the code: public int Test { get{return 0;}...
7
by: mike p. | last post by:
I have a docbook xml file, and am using standard docbook 1.61.3 xsl stylesheets to do xhtml transform. Transform works fine when using MSXML. When I try to do the following using asp.net 1.1: ...
0
by: vthakur | last post by:
Hello: I have generated a c# proxy (client) from the WSDL. One of the class has a defaultValueAtribute. Like so: public class PersonInformationLoadRequest { public string DataSource;
2
by: Mike in Paradise | last post by:
Can you use the DefaultValueAttribute on Decimal PropertyFields? If so what is format for setting the Default value. Thanks... Example /// <summary> /// Field: increment value ///...
1
by: Mythran | last post by:
How can I set a DefaultValue for an array property? I don't have a project that uses this anymore, but still am curious. Of all the replies I've posted here, a simple thing like this is my...
2
by: --== Alain ==-- | last post by:
Hi, I would like to define the default value of my property. My property is from type Bitmap^, therefore i was thinking to do : but i does not work. how is it possible to define this...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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,...

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.