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 ignores it!
I´ve also tried other things like:
DefaultValue(typeof(Color), "Blue"),
DefaultValue(typeof(Color), "Color.Blue"),
DefaultValue(typeof(System.Drawing.Color), "0, 0, 255"),
DefaultValue(typeof(System.Drawing.Color), "0; 0; 255"),
Searching the net I found a lot of solutions like the ones above.
But the problem is none of them are working for me.
Any ideas?
Thanks,
timtos. 2 11394
Timtos,
The DefaultValue attribute tells the designer what the constructor of your
object considers the default value. You still need to set the default for
the backing field on the property to the default, I normally do this in the
constructor.
I normally use: DefaultValue(typeof(System.Drawing.Color), "Blue"),
Hope this helps
Jay
In the constructor of your
"timtos" <ti****@gmx.de> wrote in message
news:bi***********@news.uni-koblenz.de... 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 ignores it! I´ve also tried other things like:
DefaultValue(typeof(Color), "Blue"), DefaultValue(typeof(Color), "Color.Blue"), DefaultValue(typeof(System.Drawing.Color), "0, 0, 255"), DefaultValue(typeof(System.Drawing.Color), "0; 0; 255"),
Searching the net I found a lot of solutions like the ones above. But the problem is none of them are working for me.
Any ideas? Thanks, timtos.
Thanks for making things clear!
It is "working" now ;-)
Greetings,
timtos.
"Jay B. Harlow [MVP - Outlook]" <Ja********@email.msn.com> wrote in message news:um**************@TK2MSFTNGP12.phx.gbl... Timtos, The DefaultValue attribute tells the designer what the constructor of your object considers the default value. You still need to set the default for the backing field on the property to the default, I normally do this in the constructor.
I normally use: DefaultValue(typeof(System.Drawing.Color), "Blue"),
Hope this helps Jay
In the constructor of your "timtos" <ti****@gmx.de> wrote in message news:bi***********@news.uni-koblenz.de... 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 ignores it! I´ve also tried other things like:
DefaultValue(typeof(Color), "Blue"), DefaultValue(typeof(Color), "Color.Blue"), DefaultValue(typeof(System.Drawing.Color), "0, 0, 255"), DefaultValue(typeof(System.Drawing.Color), "0; 0; 255"),
Searching the net I found a lot of solutions like the ones above. But the problem is none of them are working for me.
Any ideas? Thanks, timtos.
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: bbrik |
last post by:
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...
|
by: Joe |
last post by:
I wrote a simple server control that inherits from the DropDownList
control. I will be using the control in an aspx page and want to
access it in a repeater. I have created a public property...
|
by: Joe |
last post by:
I am having a hard time with setting a property on a custom server
control that i am placing in a repeater. The control inherits from
DropDownList. The property is being set in the repeater using...
|
by: Lance |
last post by:
I want to be able to reset a complex property in a PropertyGrid. I know that for properties that are ValueTypes you can include System.ComponentModel.DefaultValue in the declaration of the property....
|
by: Meelis Lilbok |
last post by:
Hi
Why does property default value not work?
When i start my application and dont set value from properties window
the value is always "nothing". Whats the point off DefualtValue then?
...
|
by: Shadow Lynx |
last post by:
Language: VB.Net 2.0 (Windows Application)
IDE: MS VB 2005 Exp. Ed.
Summary: Setting a DefaultValue of type Decimal for the Property of a
UserControl does not work properly - the value appears...
|
by: Eric |
last post by:
Hi Everyone,
I'm writing a UserControl that exposes a property of the type
System.Drawing.Image, like this:
Public Property DefaultImage() As Image
Get
Return propDefaultImage
End Get...
|
by: Andrus |
last post by:
I'm implementing entity object which should populate its properties from
database when property is first referenced.
In RDL reports I use object properties like
MyObject.MyProperty
MyObject...
|
by: Johnny Jörgensen |
last post by:
Does anybody know how to correctly specify the defaultvalue attribute for a
property whose type is an enum.
Example:
Public Enum TestValues
Value1=1
Value2=2
End Enum
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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...
| |