Hi,
I'm doing a control that has a custom color property and i want to set a
default value. I tried several combinations using the DefaultValue atribute
but it didn't work. It must be a constant, so i can't do:
[DefaultValue(Color.Red)]
public Color MyColor { ... }
I also tried:
[DefaultValue(typeof(Color), "255; 0; 0")]
public Color MyColor { ... }
and it didn't work.
Thanks in advance,
Bernardo 5 12743
Use a "ShouldSerializeX" method. http://msdn.microsoft.com/library/de...setmethods.asp
--
Tim Wilson
..Net Compact Framework MVP
"bbrik" <bb***@discussions.microsoft.com> wrote in message
news:E2**********************************@microsof t.com... Hi,
I'm doing a control that has a custom color property and i want to set a default value. I tried several combinations using the DefaultValue
atribute but it didn't work. It must be a constant, so i can't do:
[DefaultValue(Color.Red)] public Color MyColor { ... }
I also tried:
[DefaultValue(typeof(Color), "255; 0; 0")] public Color MyColor { ... }
and it didn't work.
Thanks in advance,
Bernardo
bbrik,
Have you tried:
[DefaultValue(typeof(Color), "Red")]
public Color MyColor
That should work. You need to use the string that is used in the
property grid for that value (Red is a defined color and the type converter
used for color acknowleges it).
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"bbrik" <bb***@discussions.microsoft.com> wrote in message
news:E2**********************************@microsof t.com... Hi,
I'm doing a control that has a custom color property and i want to set a default value. I tried several combinations using the DefaultValue atribute but it didn't work. It must be a constant, so i can't do:
[DefaultValue(Color.Red)] public Color MyColor { ... }
I also tried:
[DefaultValue(typeof(Color), "255; 0; 0")] public Color MyColor { ... }
and it didn't work.
Thanks in advance,
Bernardo
Hi,
That worked, thanks! What is strange is that if you type "192;192;192" in
the property grid it gets converted to the color... so why the type converter
works at design time but not in the atribute?
Anyway, I get stuck with the predefined colors... It's ok because the name
Silver maps to the color i wanted, but it should accept custom colors.
What is also strange is that when I reset the color, it still gets Bold font
face on the property grid and I still can call reset again...
thanks again!
bbrik
"Nicholas Paldino [.NET/C# MVP]" wrote: bbrik,
Have you tried:
[DefaultValue(typeof(Color), "Red")] public Color MyColor
That should work. You need to use the string that is used in the property grid for that value (Red is a defined color and the type converter used for color acknowleges it).
Hope this helps.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard.caspershouse.com
"bbrik" <bb***@discussions.microsoft.com> wrote in message news:E2**********************************@microsof t.com... Hi,
I'm doing a control that has a custom color property and i want to set a default value. I tried several combinations using the DefaultValue atribute but it didn't work. It must be a constant, so i can't do:
[DefaultValue(Color.Red)] public Color MyColor { ... }
I also tried:
[DefaultValue(typeof(Color), "255; 0; 0")] public Color MyColor { ... }
and it didn't work.
Thanks in advance,
Bernardo
Hi,
the designer totally ignored my ShouldSerializeMaskColor property
any ideas?
thanks!
"Tim Wilson" wrote: Use a "ShouldSerializeX" method. http://msdn.microsoft.com/library/de...setmethods.asp
-- Tim Wilson ..Net Compact Framework MVP
"bbrik" <bb***@discussions.microsoft.com> wrote in message news:E2**********************************@microsof t.com... Hi,
I'm doing a control that has a custom color property and i want to set a default value. I tried several combinations using the DefaultValue atribute but it didn't work. It must be a constant, so i can't do:
[DefaultValue(Color.Red)] public Color MyColor { ... }
I also tried:
[DefaultValue(typeof(Color), "255; 0; 0")] public Color MyColor { ... }
and it didn't work.
Thanks in advance,
Bernardo
I assume that your property is named "MaskColor" and you have a method that
looks something like this...
public bool ShouldSerializeMaskColor()
{
return maskColorValue != (default color);
}
If the code is correct then ensure that you've rebuilt the assembly and are
not still referencing an old version.
--
Tim Wilson
..Net Compact Framework MVP
"bbrik" <bb***@discussions.microsoft.com> wrote in message
news:32**********************************@microsof t.com... Hi,
the designer totally ignored my ShouldSerializeMaskColor property
any ideas?
thanks!
"Tim Wilson" wrote:
Use a "ShouldSerializeX" method. http://msdn.microsoft.com/library/de...setmethods.asp -- Tim Wilson ..Net Compact Framework MVP
"bbrik" <bb***@discussions.microsoft.com> wrote in message news:E2**********************************@microsof t.com... Hi,
I'm doing a control that has a custom color property and i want to set
a default value. I tried several combinations using the DefaultValue atribute but it didn't work. It must be a constant, so i can't do:
[DefaultValue(Color.Red)] public Color MyColor { ... }
I also tried:
[DefaultValue(typeof(Color), "255; 0; 0")] public Color MyColor { ... }
and it didn't work.
Thanks in advance,
Bernardo
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Maurice Mertens |
last post by:
Hi,
I have an Access database in which I defined default values for certain
columns. On my windows forms I've got controls bound to the dataset, The
problem is that when I add a new row to the...
|
by: timtos |
last post by:
I want to set a color property of a user control by default.
I am doing it like this:
....
DefaultValue(typeof(System.Drawing.Color), "Blue"),
....
The compiler likes it but my program...
|
by: dan |
last post by:
Hi NG,
i am developing an asp.net Custom control which consist of some TextBoxes,
Button, ... .
To let the user of that control set for example the width of the TextBox,
the class has a...
|
by: Steve |
last post by:
Hi, I would like to set the default value of a property on my control by:
but can't because SystemColors.WindowText is not a constant. Microsoft
controls do it, can I - is there a work round?...
|
by: job |
last post by:
I'm having trouble getting the DefaultValue property attribute on my
server control show up in design time.
Here my property code:
<Bindable(True), _
Category("Misc"), _...
| |
by: MLH |
last post by:
On frmVehicleEntryForm...
I wanted to change the DefaultValue property
of one of my textbox controls on a form from within
code. I wanted the setting to be no setting - as if
nothing had ever...
|
by: tony |
last post by:
Hello!!
I have some demo programs written in C# and they have this construction
"" see below.
I haven't seen this before so what does it mean ?
public bool ShowDropDownButtons
{
get {...
|
by: Peter Hartlén |
last post by:
Hi!
What's the correct syntax for the default value design time attribute, using
classdiagram view and Custom Attributes dialog.
For a boolean:
DefaultValue(true)
DefaultValue("true")...
|
by: =?Utf-8?B?bWljaGFlbCBzb3JlbnM=?= |
last post by:
Prior to C# 3.0, I would typically define a property of a custom user control
with pattern A:
=== PATTERN A ==========
private bool myBool = true;
public bool MyBool {
get { return myBool; }...
|
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...
|
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...
| |
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: 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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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 ...
|
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...
| |